From d2ded3df78e70834cc70bcffa8600471fc2828e2 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 6 Jun 2023 21:59:04 +0000 Subject: [PATCH] CodeGen from PR 24326 in Azure/azure-rest-api-specs Merge bbdeb1fade0614a3f7833a00680e0951ba8beeb5 into aa1f08c2bfb9bef613f963aaf971a25558151330 --- .../armcontainerservicefleet/CHANGELOG.md | 7 + .../armcontainerservicefleet/LICENSE.txt | 21 + .../armcontainerservicefleet/README.md | 85 ++ .../armcontainerservicefleet/autorest.md | 13 + .../armcontainerservicefleet/build.go | 7 + .../armcontainerservicefleet/ci.yml | 28 + .../client_factory.go | 59 + .../armcontainerservicefleet/constants.go | 185 +++ .../fleetmembers_client.go | 397 ++++++ .../armcontainerservicefleet/fleets_client.go | 488 +++++++ .../armcontainerservicefleet/go.mod | 13 + .../armcontainerservicefleet/go.sum | 15 + .../armcontainerservicefleet/models.go | 549 ++++++++ .../armcontainerservicefleet/models_serde.go | 1174 +++++++++++++++++ .../operations_client.go | 94 ++ .../response_types.go | 105 ++ .../armcontainerservicefleet/time_rfc3339.go | 87 ++ .../updateruns_client.go | 478 +++++++ 18 files changed, 3805 insertions(+) create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/CHANGELOG.md create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/LICENSE.txt create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/README.md create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/autorest.md create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/build.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/ci.yml create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/client_factory.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/constants.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/fleetmembers_client.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/fleets_client.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/go.mod create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/go.sum create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/models.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/models_serde.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/operations_client.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/response_types.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/time_rfc3339.go create mode 100644 sdk/resourcemanager/containerservice/armcontainerservicefleet/updateruns_client.go diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/CHANGELOG.md b/sdk/resourcemanager/containerservice/armcontainerservicefleet/CHANGELOG.md new file mode 100644 index 000000000000..bb8964d9af98 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-06-06) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservicefleet` 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/containerservice/armcontainerservicefleet/LICENSE.txt b/sdk/resourcemanager/containerservice/armcontainerservicefleet/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/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/containerservice/armcontainerservicefleet/README.md b/sdk/resourcemanager/containerservice/armcontainerservicefleet/README.md new file mode 100644 index 000000000000..43be62108e90 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/README.md @@ -0,0 +1,85 @@ +# Azure Containerservice Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservicefleet)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservicefleet) + +The `armcontainerservicefleet` module provides operations for working with Azure Containerservice. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerservice/armcontainerservicefleet) + +# 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 Containerservice module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservicefleet +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Containerservice. 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 Containerservice 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 := armcontainerservicefleet.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, + }, +} +client, err := armcontainerservicefleet.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.NewFleetMembersClient() +``` + +## 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 `Containerservice` 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/containerservice/armcontainerservicefleet/autorest.md b/sdk/resourcemanager/containerservice/armcontainerservicefleet/autorest.md new file mode 100644 index 000000000000..44352ab5fd85 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/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/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: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/build.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/build.go new file mode 100644 index 000000000000..5b57491975cd --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/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/containerservice/armcontainerservicefleet + +package armcontainerservicefleet diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/ci.yml b/sdk/resourcemanager/containerservice/armcontainerservicefleet/ci.yml new file mode 100644 index 000000000000..9ba35fa9362b --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/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/containerservice/armcontainerservicefleet/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerservice/armcontainerservicefleet/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/containerservice/armcontainerservicefleet' diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/client_factory.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/client_factory.go new file mode 100644 index 000000000000..477ac8452175 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/client_factory.go @@ -0,0 +1,59 @@ +//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 + +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 + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - 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) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFleetsClient() *FleetsClient { + subClient, _ := NewFleetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFleetMembersClient() *FleetMembersClient { + subClient, _ := NewFleetMembersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUpdateRunsClient() *UpdateRunsClient { + subClient, _ := NewUpdateRunsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/constants.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/constants.go new file mode 100644 index 000000000000..18346c90dc7d --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/constants.go @@ -0,0 +1,185 @@ +//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 + +const ( + moduleName = "armcontainerservicefleet" + 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, + } +} + +// 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, + } +} + +// FleetMemberProvisioningState - The provisioning state of the last accepted operation. +type FleetMemberProvisioningState string + +const ( + // FleetMemberProvisioningStateCanceled - Resource creation was canceled. + FleetMemberProvisioningStateCanceled FleetMemberProvisioningState = "Canceled" + // FleetMemberProvisioningStateFailed - Resource creation failed. + FleetMemberProvisioningStateFailed FleetMemberProvisioningState = "Failed" + FleetMemberProvisioningStateJoining FleetMemberProvisioningState = "Joining" + FleetMemberProvisioningStateLeaving FleetMemberProvisioningState = "Leaving" + // FleetMemberProvisioningStateSucceeded - Resource has been created. + FleetMemberProvisioningStateSucceeded FleetMemberProvisioningState = "Succeeded" + FleetMemberProvisioningStateUpdating FleetMemberProvisioningState = "Updating" +) + +// PossibleFleetMemberProvisioningStateValues returns the possible values for the FleetMemberProvisioningState const type. +func PossibleFleetMemberProvisioningStateValues() []FleetMemberProvisioningState { + return []FleetMemberProvisioningState{ + FleetMemberProvisioningStateCanceled, + FleetMemberProvisioningStateFailed, + FleetMemberProvisioningStateJoining, + FleetMemberProvisioningStateLeaving, + FleetMemberProvisioningStateSucceeded, + FleetMemberProvisioningStateUpdating, + } +} + +// FleetProvisioningState - The provisioning state of the last accepted operation. +type FleetProvisioningState string + +const ( + // FleetProvisioningStateCanceled - Resource creation was canceled. + FleetProvisioningStateCanceled FleetProvisioningState = "Canceled" + FleetProvisioningStateCreating FleetProvisioningState = "Creating" + FleetProvisioningStateDeleting FleetProvisioningState = "Deleting" + // FleetProvisioningStateFailed - Resource creation failed. + FleetProvisioningStateFailed FleetProvisioningState = "Failed" + // FleetProvisioningStateSucceeded - Resource has been created. + FleetProvisioningStateSucceeded FleetProvisioningState = "Succeeded" + FleetProvisioningStateUpdating FleetProvisioningState = "Updating" +) + +// PossibleFleetProvisioningStateValues returns the possible values for the FleetProvisioningState const type. +func PossibleFleetProvisioningStateValues() []FleetProvisioningState { + return []FleetProvisioningState{ + FleetProvisioningStateCanceled, + FleetProvisioningStateCreating, + FleetProvisioningStateDeleting, + FleetProvisioningStateFailed, + FleetProvisioningStateSucceeded, + FleetProvisioningStateUpdating, + } +} + +// ManagedClusterUpgradeType - The type of upgrade to perform when targeting ManagedClusters. +type ManagedClusterUpgradeType string + +const ( + // ManagedClusterUpgradeTypeFull - Full upgrades the control plane and all agent pools of the target ManagedClusters. + ManagedClusterUpgradeTypeFull ManagedClusterUpgradeType = "Full" + // ManagedClusterUpgradeTypeNodeImageOnly - NodeImageOnly upgrades only the node images of the target ManagedClusters. + ManagedClusterUpgradeTypeNodeImageOnly ManagedClusterUpgradeType = "NodeImageOnly" +) + +// PossibleManagedClusterUpgradeTypeValues returns the possible values for the ManagedClusterUpgradeType const type. +func PossibleManagedClusterUpgradeTypeValues() []ManagedClusterUpgradeType { + return []ManagedClusterUpgradeType{ + ManagedClusterUpgradeTypeFull, + ManagedClusterUpgradeTypeNodeImageOnly, + } +} + +// 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, + } +} + +// UpdateRunProvisioningState - The provisioning state of the UpdateRun resource. +type UpdateRunProvisioningState string + +const ( + // UpdateRunProvisioningStateCanceled - Resource creation was canceled. + UpdateRunProvisioningStateCanceled UpdateRunProvisioningState = "Canceled" + // UpdateRunProvisioningStateFailed - Resource creation failed. + UpdateRunProvisioningStateFailed UpdateRunProvisioningState = "Failed" + // UpdateRunProvisioningStateSucceeded - Resource has been created. + UpdateRunProvisioningStateSucceeded UpdateRunProvisioningState = "Succeeded" +) + +// PossibleUpdateRunProvisioningStateValues returns the possible values for the UpdateRunProvisioningState const type. +func PossibleUpdateRunProvisioningStateValues() []UpdateRunProvisioningState { + return []UpdateRunProvisioningState{ + UpdateRunProvisioningStateCanceled, + UpdateRunProvisioningStateFailed, + UpdateRunProvisioningStateSucceeded, + } +} + +// UpdateState - The state of the UpdateRun, UpdateStage, UpdateGroup, or MemberUpdate. +type UpdateState string + +const ( + UpdateStateCompleted UpdateState = "Completed" + UpdateStateFailed UpdateState = "Failed" + UpdateStateNotStarted UpdateState = "NotStarted" + UpdateStateRunning UpdateState = "Running" + UpdateStateStopped UpdateState = "Stopped" + UpdateStateStopping UpdateState = "Stopping" +) + +// PossibleUpdateStateValues returns the possible values for the UpdateState const type. +func PossibleUpdateStateValues() []UpdateState { + return []UpdateState{ + UpdateStateCompleted, + UpdateStateFailed, + UpdateStateNotStarted, + UpdateStateRunning, + UpdateStateStopped, + UpdateStateStopping, + } +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleetmembers_client.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleetmembers_client.go new file mode 100644 index 000000000000..38faa05f1b95 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleetmembers_client.go @@ -0,0 +1,397 @@ +//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 + +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" +) + +// FleetMembersClient contains the methods for the FleetMembers group. +// Don't use this type directly, use NewFleetMembersClient() instead. +type FleetMembersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFleetMembersClient creates a new instance of FleetMembersClient 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 NewFleetMembersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FleetMembersClient, error) { + cl, err := arm.NewClient(moduleName+".FleetMembersClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FleetMembersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - fleetMemberName - The name of the Fleet member resource. +// - resource - Resource create parameters. +// - options - FleetMembersClientBeginCreateOptions contains the optional parameters for the FleetMembersClient.BeginCreate +// method. +func (client *FleetMembersClient) BeginCreate(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, resource FleetMember, options *FleetMembersClientBeginCreateOptions) (*runtime.Poller[FleetMembersClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, fleetName, fleetMemberName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FleetMembersClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[FleetMembersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Create a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *FleetMembersClient) create(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, resource FleetMember, options *FleetMembersClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, fleetName, fleetMemberName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *FleetMembersClient) createCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, resource FleetMember, options *FleetMembersClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if fleetMemberName == "" { + return nil, errors.New("parameter fleetMemberName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetMemberName}", url.PathEscape(fleetMemberName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - fleetMemberName - The name of the Fleet member resource. +// - options - FleetMembersClientBeginDeleteOptions contains the optional parameters for the FleetMembersClient.BeginDelete +// method. +func (client *FleetMembersClient) BeginDelete(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, options *FleetMembersClientBeginDeleteOptions) (*runtime.Poller[FleetMembersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, fleetName, fleetMemberName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FleetMembersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[FleetMembersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *FleetMembersClient) deleteOperation(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, options *FleetMembersClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, fleetName, fleetMemberName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FleetMembersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, options *FleetMembersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if fleetMemberName == "" { + return nil, errors.New("parameter fleetMemberName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetMemberName}", url.PathEscape(fleetMemberName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - fleetMemberName - The name of the Fleet member resource. +// - options - FleetMembersClientGetOptions contains the optional parameters for the FleetMembersClient.Get method. +func (client *FleetMembersClient) Get(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, options *FleetMembersClientGetOptions) (FleetMembersClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, fleetName, fleetMemberName, options) + if err != nil { + return FleetMembersClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetMembersClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetMembersClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *FleetMembersClient) getCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, options *FleetMembersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if fleetMemberName == "" { + return nil, errors.New("parameter fleetMemberName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetMemberName}", url.PathEscape(fleetMemberName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FleetMembersClient) getHandleResponse(resp *http.Response) (FleetMembersClientGetResponse, error) { + result := FleetMembersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetMember); err != nil { + return FleetMembersClientGetResponse{}, err + } + return result, nil +} + +// NewListByFleetPager - List FleetMember resources by Fleet +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - options - FleetMembersClientListByFleetOptions contains the optional parameters for the FleetMembersClient.NewListByFleetPager +// method. +func (client *FleetMembersClient) NewListByFleetPager(resourceGroupName string, fleetName string, options *FleetMembersClientListByFleetOptions) *runtime.Pager[FleetMembersClientListByFleetResponse] { + return runtime.NewPager(runtime.PagingHandler[FleetMembersClientListByFleetResponse]{ + More: func(page FleetMembersClientListByFleetResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FleetMembersClientListByFleetResponse) (FleetMembersClientListByFleetResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByFleetCreateRequest(ctx, resourceGroupName, fleetName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FleetMembersClientListByFleetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetMembersClientListByFleetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetMembersClientListByFleetResponse{}, runtime.NewResponseError(resp) + } + return client.listByFleetHandleResponse(resp) + }, + }) +} + +// listByFleetCreateRequest creates the ListByFleet request. +func (client *FleetMembersClient) listByFleetCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, options *FleetMembersClientListByFleetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByFleetHandleResponse handles the ListByFleet response. +func (client *FleetMembersClient) listByFleetHandleResponse(resp *http.Response) (FleetMembersClientListByFleetResponse, error) { + result := FleetMembersClientListByFleetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetMemberListResult); err != nil { + return FleetMembersClientListByFleetResponse{}, err + } + return result, nil +} + +// Update - Update a FleetMember +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - fleetMemberName - The name of the Fleet member resource. +// - properties - The resource properties to be updated. +// - options - FleetMembersClientUpdateOptions contains the optional parameters for the FleetMembersClient.Update method. +func (client *FleetMembersClient) Update(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, properties FleetMemberUpdate, options *FleetMembersClientUpdateOptions) (FleetMembersClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, fleetName, fleetMemberName, properties, options) + if err != nil { + return FleetMembersClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetMembersClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetMembersClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *FleetMembersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, fleetMemberName string, properties FleetMemberUpdate, options *FleetMembersClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if fleetMemberName == "" { + return nil, errors.New("parameter fleetMemberName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetMemberName}", url.PathEscape(fleetMemberName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *FleetMembersClient) updateHandleResponse(resp *http.Response) (FleetMembersClientUpdateResponse, error) { + result := FleetMembersClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetMember); err != nil { + return FleetMembersClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleets_client.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleets_client.go new file mode 100644 index 000000000000..0da291ce353b --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/fleets_client.go @@ -0,0 +1,488 @@ +//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 + +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" +) + +// FleetsClient contains the methods for the Fleets group. +// Don't use this type directly, use NewFleetsClient() instead. +type FleetsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFleetsClient creates a new instance of FleetsClient 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 NewFleetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FleetsClient, error) { + cl, err := arm.NewClient(moduleName+".FleetsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FleetsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a Fleet. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - resource - Resource create parameters. +// - options - FleetsClientBeginCreateOrUpdateOptions contains the optional parameters for the FleetsClient.BeginCreateOrUpdate +// method. +func (client *FleetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, fleetName string, resource Fleet, options *FleetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[FleetsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, fleetName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FleetsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[FleetsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Creates or updates a Fleet. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *FleetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, fleetName string, resource Fleet, options *FleetsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, fleetName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *FleetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, resource Fleet, options *FleetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Fleet +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - options - FleetsClientBeginDeleteOptions contains the optional parameters for the FleetsClient.BeginDelete method. +func (client *FleetsClient) BeginDelete(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientBeginDeleteOptions) (*runtime.Poller[FleetsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, fleetName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FleetsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[FleetsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Fleet +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *FleetsClient) deleteOperation(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, fleetName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FleetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a Fleet. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - options - FleetsClientGetOptions contains the optional parameters for the FleetsClient.Get method. +func (client *FleetsClient) Get(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientGetOptions) (FleetsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, fleetName, options) + if err != nil { + return FleetsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *FleetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FleetsClient) getHandleResponse(resp *http.Response) (FleetsClientGetResponse, error) { + result := FleetsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Fleet); err != nil { + return FleetsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists fleets in the specified subscription and resource group. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - FleetsClientListByResourceGroupOptions contains the optional parameters for the FleetsClient.NewListByResourceGroupPager +// method. +func (client *FleetsClient) NewListByResourceGroupPager(resourceGroupName string, options *FleetsClientListByResourceGroupOptions) *runtime.Pager[FleetsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[FleetsClientListByResourceGroupResponse]{ + More: func(page FleetsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FleetsClientListByResourceGroupResponse) (FleetsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FleetsClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *FleetsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *FleetsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets" + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *FleetsClient) listByResourceGroupHandleResponse(resp *http.Response) (FleetsClientListByResourceGroupResponse, error) { + result := FleetsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetListResult); err != nil { + return FleetsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists fleets in the specified subscription. +// +// Generated from API version 2023-03-15-preview +// - options - FleetsClientListBySubscriptionOptions contains the optional parameters for the FleetsClient.NewListBySubscriptionPager +// method. +func (client *FleetsClient) NewListBySubscriptionPager(options *FleetsClientListBySubscriptionOptions) *runtime.Pager[FleetsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[FleetsClientListBySubscriptionResponse]{ + More: func(page FleetsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FleetsClientListBySubscriptionResponse) (FleetsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FleetsClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *FleetsClient) listBySubscriptionCreateRequest(ctx context.Context, options *FleetsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/fleets" + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *FleetsClient) listBySubscriptionHandleResponse(resp *http.Response) (FleetsClientListBySubscriptionResponse, error) { + result := FleetsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetListResult); err != nil { + return FleetsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// ListCredentials - Lists the user credentials of a Fleet. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - options - FleetsClientListCredentialsOptions contains the optional parameters for the FleetsClient.ListCredentials method. +func (client *FleetsClient) ListCredentials(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientListCredentialsOptions) (FleetsClientListCredentialsResponse, error) { + req, err := client.listCredentialsCreateRequest(ctx, resourceGroupName, fleetName, options) + if err != nil { + return FleetsClientListCredentialsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetsClientListCredentialsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetsClientListCredentialsResponse{}, runtime.NewResponseError(resp) + } + return client.listCredentialsHandleResponse(resp) +} + +// listCredentialsCreateRequest creates the ListCredentials request. +func (client *FleetsClient) listCredentialsCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, options *FleetsClientListCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/listCredentials" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listCredentialsHandleResponse handles the ListCredentials response. +func (client *FleetsClient) listCredentialsHandleResponse(resp *http.Response) (FleetsClientListCredentialsResponse, error) { + result := FleetsClientListCredentialsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FleetCredentialResults); err != nil { + return FleetsClientListCredentialsResponse{}, err + } + return result, nil +} + +// Update - Update a Fleet +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - properties - The resource properties to be updated. +// - options - FleetsClientUpdateOptions contains the optional parameters for the FleetsClient.Update method. +func (client *FleetsClient) Update(ctx context.Context, resourceGroupName string, fleetName string, properties FleetPatch, options *FleetsClientUpdateOptions) (FleetsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, fleetName, properties, options) + if err != nil { + return FleetsClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FleetsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FleetsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *FleetsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, properties FleetPatch, options *FleetsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *FleetsClient) updateHandleResponse(resp *http.Response) (FleetsClientUpdateResponse, error) { + result := FleetsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Fleet); err != nil { + return FleetsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.mod b/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.mod new file mode 100644 index 000000000000..d4667ccad002 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservicefleet + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.sum b/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.sum new file mode 100644 index 000000000000..f54c298864a1 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/models.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/models.go new file mode 100644 index 000000000000..9c8fa07aaf2e --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/models.go @@ -0,0 +1,549 @@ +//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 + +import "time" + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// Fleet - The Fleet resource. +type Fleet struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *FleetProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. + // Entity tags are used for comparing two or more entities from the same requested resource. + // HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + // (section 14.27) header fields. + ETag *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 +} + +// FleetCredentialResult - One credential result item. +type FleetCredentialResult struct { + // READ-ONLY; The name of the credential. + Name *string + + // READ-ONLY; Base64-encoded Kubernetes configuration file. + Value []byte +} + +// FleetCredentialResults - The Credential results response. +type FleetCredentialResults struct { + // READ-ONLY; Array of base64-encoded Kubernetes configuration files. + Kubeconfigs []*FleetCredentialResult +} + +// FleetHubProfile - The FleetHubProfile configures the fleet hub. +type FleetHubProfile struct { + // DNS prefix used to create the FQDN for the Fleet hub. + DNSPrefix *string + + // READ-ONLY; The FQDN of the Fleet hub. + Fqdn *string + + // READ-ONLY; The Kubernetes version of the Fleet hub. + KubernetesVersion *string +} + +// FleetListResult - The response of a Fleet list operation. +type FleetListResult struct { + // REQUIRED; The Fleet items on this page + Value []*Fleet + + // The link to the next page of items + NextLink *string +} + +// FleetMember - A member of the Fleet. It contains a reference to an existing Kubernetes cluster on Azure. +type FleetMember struct { + // The resource-specific properties for this resource. + Properties *FleetMemberProperties + + // READ-ONLY; If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. + // Entity tags are used for comparing two or more entities from the same requested resource. + // HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + // (section 14.27) header fields. + ETag *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 +} + +// FleetMemberListResult - The response of a FleetMember list operation. +type FleetMemberListResult struct { + // REQUIRED; The FleetMember items on this page + Value []*FleetMember + + // The link to the next page of items + NextLink *string +} + +// FleetMemberProperties - A member of the Fleet. It contains a reference to an existing Kubernetes cluster on Azure. +type FleetMemberProperties struct { + // REQUIRED; The ARM resource id of the cluster that joins the Fleet. Must be a valid Azure resource id. e.g.: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{clusterName}'. + ClusterResourceID *string + + // The group this member belongs to for multi-cluster update management. + Group *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *FleetMemberProvisioningState +} + +// FleetMemberUpdate - The type used for update operations of the FleetMember. +type FleetMemberUpdate struct { + // The updatable properties of the FleetMember. + Properties *FleetMemberUpdateProperties +} + +// FleetMemberUpdateProperties - The updatable properties of the FleetMember. +type FleetMemberUpdateProperties struct { + // The group this member belongs to for multi-cluster update management. + Group *string +} + +// FleetMembersClientBeginCreateOptions contains the optional parameters for the FleetMembersClient.BeginCreate method. +type FleetMembersClientBeginCreateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // The request should only proceed if no entity matches this string. + IfNoneMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FleetMembersClientBeginDeleteOptions contains the optional parameters for the FleetMembersClient.BeginDelete method. +type FleetMembersClientBeginDeleteOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FleetMembersClientGetOptions contains the optional parameters for the FleetMembersClient.Get method. +type FleetMembersClientGetOptions struct { + // placeholder for future optional parameters +} + +// FleetMembersClientListByFleetOptions contains the optional parameters for the FleetMembersClient.NewListByFleetPager method. +type FleetMembersClientListByFleetOptions struct { + // placeholder for future optional parameters +} + +// FleetMembersClientUpdateOptions contains the optional parameters for the FleetMembersClient.Update method. +type FleetMembersClientUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string +} + +// FleetPatch - Properties of a Fleet that can be patched. +type FleetPatch struct { + // Resource tags. + Tags map[string]*string +} + +// FleetProperties - Fleet properties. +type FleetProperties struct { + // The FleetHubProfile configures the Fleet's hub. + HubProfile *FleetHubProfile + + // READ-ONLY; The status of the last operation. + ProvisioningState *FleetProvisioningState +} + +// FleetsClientBeginCreateOrUpdateOptions contains the optional parameters for the FleetsClient.BeginCreateOrUpdate method. +type FleetsClientBeginCreateOrUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // The request should only proceed if no entity matches this string. + IfNoneMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FleetsClientBeginDeleteOptions contains the optional parameters for the FleetsClient.BeginDelete method. +type FleetsClientBeginDeleteOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FleetsClientGetOptions contains the optional parameters for the FleetsClient.Get method. +type FleetsClientGetOptions struct { + // placeholder for future optional parameters +} + +// FleetsClientListByResourceGroupOptions contains the optional parameters for the FleetsClient.NewListByResourceGroupPager +// method. +type FleetsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// FleetsClientListBySubscriptionOptions contains the optional parameters for the FleetsClient.NewListBySubscriptionPager +// method. +type FleetsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// FleetsClientListCredentialsOptions contains the optional parameters for the FleetsClient.ListCredentials method. +type FleetsClientListCredentialsOptions struct { + // placeholder for future optional parameters +} + +// FleetsClientUpdateOptions contains the optional parameters for the FleetsClient.Update method. +type FleetsClientUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string +} + +// ManagedClusterUpdate - The update to be applied to the ManagedClusters. +type ManagedClusterUpdate struct { + // REQUIRED; The upgrade to apply to the ManagedClusters. + Upgrade *ManagedClusterUpgradeSpec +} + +// ManagedClusterUpgradeSpec - The upgrade to apply to a ManagedCluster. +type ManagedClusterUpgradeSpec struct { + // REQUIRED; The upgrade type. Full requires the KubernetesVersion property to be set. NodeImageOnly requires the KubernetesVersion + // property not to be set. + Type *ManagedClusterUpgradeType + + // The Kubernetes version to upgrade the member clusters to. + KubernetesVersion *string +} + +// MemberUpdateStatus - The status of a member update operation. +type MemberUpdateStatus struct { + // READ-ONLY; The Azure resource id of the target Kubernetes cluster. + ClusterResourceID *string + + // READ-ONLY; The name of the FleetMember. + Name *string + + // READ-ONLY; The operation resource id of the latest attempt to perform the operation. + OperationID *string + + // READ-ONLY; The status of the MemberUpdate operation. + Status *UpdateStatus +} + +// 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 +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // 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 +} + +// UpdateGroup - A group to be updated. +type UpdateGroup struct { + // REQUIRED; The name of the Fleet member group to update. It should match the name of an existing FleetMember group. A group + // can only appear once across all UpdateStages in the UpdateRun. + Name *string +} + +// UpdateGroupStatus - The status of a UpdateGroup. +type UpdateGroupStatus struct { + // READ-ONLY; The list of member this UpdateGroup updates. + Members []*MemberUpdateStatus + + // READ-ONLY; The name of the UpdateGroup. + Name *string + + // READ-ONLY; The status of the UpdateGroup. + Status *UpdateStatus +} + +// UpdateRun - An UpdateRun is a multi-stage process to perform update operations across members of a Fleet. +type UpdateRun struct { + // The resource-specific properties for this resource. + Properties *UpdateRunProperties + + // READ-ONLY; If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. + // Entity tags are used for comparing two or more entities from the same requested resource. + // HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + // (section 14.27) header fields. + ETag *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 +} + +// UpdateRunListResult - The response of a UpdateRun list operation. +type UpdateRunListResult struct { + // REQUIRED; The UpdateRun items on this page + Value []*UpdateRun + + // The link to the next page of items + NextLink *string +} + +// UpdateRunProperties - The properties of the UpdateRun. +type UpdateRunProperties struct { + // REQUIRED; The update to be applied to all clusters in the UpdateRun. The managedClusterUpdate can be modified until the + // run is started. + ManagedClusterUpdate *ManagedClusterUpdate + + // The strategy defines the order in which the clusters will be updated. If not set, all members will be updated sequentially. + // The UpdateRun status will show a single UpdateStage and a single UpdateGroup + // targeting all members. The strategy of the UpdateRun can be modified until the run is started. + Strategy *UpdateRunStrategy + + // READ-ONLY; The provisioning state of the UpdateRun resource. + ProvisioningState *UpdateRunProvisioningState + + // READ-ONLY; The status of the UpdateRun. + Status *UpdateRunStatus +} + +// UpdateRunStatus - The status of a UpdateRun. +type UpdateRunStatus struct { + // READ-ONLY; The stages composing an update run. Stages are run sequentially withing an UpdateRun. + Stages []*UpdateStageStatus + + // READ-ONLY; The status of the UpdateRun. + Status *UpdateStatus +} + +// UpdateRunStrategy - The UpdateRunStrategy configures the sequence of Stages and Groups in which the clusters will be updated. +type UpdateRunStrategy struct { + // REQUIRED; The list of stages that compose this update run. + Stages []*UpdateStage +} + +// UpdateRunsClientBeginCreateOrUpdateOptions contains the optional parameters for the UpdateRunsClient.BeginCreateOrUpdate +// method. +type UpdateRunsClientBeginCreateOrUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // The request should only proceed if no entity matches this string. + IfNoneMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UpdateRunsClientBeginDeleteOptions contains the optional parameters for the UpdateRunsClient.BeginDelete method. +type UpdateRunsClientBeginDeleteOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UpdateRunsClientBeginStartOptions contains the optional parameters for the UpdateRunsClient.BeginStart method. +type UpdateRunsClientBeginStartOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UpdateRunsClientBeginStopOptions contains the optional parameters for the UpdateRunsClient.BeginStop method. +type UpdateRunsClientBeginStopOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UpdateRunsClientGetOptions contains the optional parameters for the UpdateRunsClient.Get method. +type UpdateRunsClientGetOptions struct { + // placeholder for future optional parameters +} + +// UpdateRunsClientListByFleetOptions contains the optional parameters for the UpdateRunsClient.NewListByFleetPager method. +type UpdateRunsClientListByFleetOptions struct { + // placeholder for future optional parameters +} + +// UpdateStage - Contains the groups to be updated by an UpdateRun. Update order: +// * Sequential between stages: Stages run sequentially. The previous stage must complete before the next one starts. +// * Parallel within a stage: Groups within a stage run in parallel. +// * Sequential within a group: Clusters within a group are updated sequentially. +type UpdateStage struct { + // REQUIRED; The name of the stage. Must be unique within the UpdateRun. + Name *string + + // The time in seconds to wait at the end of this stage before starting the next one. Defaults to 0 seconds if unspecified. + AfterStageWaitInSeconds *int32 + + // A list of group names that compose the stage. The groups will be updated in parallel. Each group name can only appear once + // in the UpdateRun. + Groups []*UpdateGroup +} + +// UpdateStageStatus - The status of a UpdateStage. +type UpdateStageStatus struct { + // READ-ONLY; The status of the wait period configured on the UpdateStage. + AfterStageWaitStatus *WaitStatus + + // READ-ONLY; The list of groups to be updated as part of this UpdateStage. + Groups []*UpdateGroupStatus + + // READ-ONLY; The name of the UpdateStage. + Name *string + + // READ-ONLY; The status of the UpdateStage. + Status *UpdateStatus +} + +// UpdateStatus - The status for an operation or group of operations. +type UpdateStatus struct { + // READ-ONLY; The time the operation or group was completed. + CompletedTime *time.Time + + // READ-ONLY; The error details when a failure is encountered. + Error *ErrorDetail + + // READ-ONLY; The time the operation or group was started. + StartTime *time.Time + + // READ-ONLY; The State of the operation or group. + State *UpdateState +} + +// WaitStatus - The status of the wait duration. +type WaitStatus struct { + // READ-ONLY; The status of the wait duration. + Status *UpdateStatus + + // READ-ONLY; The wait duration configured in seconds. + WaitDurationInSeconds *int32 +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/models_serde.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/models_serde.go new file mode 100644 index 000000000000..e09cf8d6e4bd --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/models_serde.go @@ -0,0 +1,1174 @@ +//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 + +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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Fleet. +func (f Fleet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", f.ETag) + populate(objectMap, "id", f.ID) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Fleet. +func (f *Fleet) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &f.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &f.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetCredentialResult. +func (f FleetCredentialResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", f.Name) + populateByteArray(objectMap, "value", f.Value, runtime.Base64StdFormat) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetCredentialResult. +func (f *FleetCredentialResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "value": + err = runtime.DecodeByteArray(string(val), &f.Value, runtime.Base64StdFormat) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetCredentialResults. +func (f FleetCredentialResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubeconfigs", f.Kubeconfigs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetCredentialResults. +func (f *FleetCredentialResults) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kubeconfigs": + err = unpopulate(val, "Kubeconfigs", &f.Kubeconfigs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetHubProfile. +func (f FleetHubProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsPrefix", f.DNSPrefix) + populate(objectMap, "fqdn", f.Fqdn) + populate(objectMap, "kubernetesVersion", f.KubernetesVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetHubProfile. +func (f *FleetHubProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dnsPrefix": + err = unpopulate(val, "DNSPrefix", &f.DNSPrefix) + delete(rawMsg, key) + case "fqdn": + err = unpopulate(val, "Fqdn", &f.Fqdn) + delete(rawMsg, key) + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &f.KubernetesVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetListResult. +func (f FleetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetListResult. +func (f *FleetListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetMember. +func (f FleetMember) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", f.ETag) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetMember. +func (f *FleetMember) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &f.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetMemberListResult. +func (f FleetMemberListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetMemberListResult. +func (f *FleetMemberListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetMemberProperties. +func (f FleetMemberProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterResourceId", f.ClusterResourceID) + populate(objectMap, "group", f.Group) + populate(objectMap, "provisioningState", f.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetMemberProperties. +func (f *FleetMemberProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterResourceId": + err = unpopulate(val, "ClusterResourceID", &f.ClusterResourceID) + delete(rawMsg, key) + case "group": + err = unpopulate(val, "Group", &f.Group) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetMemberUpdate. +func (f FleetMemberUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", f.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetMemberUpdate. +func (f *FleetMemberUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetMemberUpdateProperties. +func (f FleetMemberUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "group", f.Group) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetMemberUpdateProperties. +func (f *FleetMemberUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "group": + err = unpopulate(val, "Group", &f.Group) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetPatch. +func (f FleetPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", f.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetPatch. +func (f *FleetPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FleetProperties. +func (f FleetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hubProfile", f.HubProfile) + populate(objectMap, "provisioningState", f.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FleetProperties. +func (f *FleetProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hubProfile": + err = unpopulate(val, "HubProfile", &f.HubProfile) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedClusterUpdate. +func (m ManagedClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "upgrade", m.Upgrade) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedClusterUpdate. +func (m *ManagedClusterUpdate) UnmarshalJSON(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 "upgrade": + err = unpopulate(val, "Upgrade", &m.Upgrade) + 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 ManagedClusterUpgradeSpec. +func (m ManagedClusterUpgradeSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubernetesVersion", m.KubernetesVersion) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedClusterUpgradeSpec. +func (m *ManagedClusterUpgradeSpec) UnmarshalJSON(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 "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &m.KubernetesVersion) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberUpdateStatus. +func (m MemberUpdateStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterResourceId", m.ClusterResourceID) + populate(objectMap, "name", m.Name) + populate(objectMap, "operationId", m.OperationID) + populate(objectMap, "status", m.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberUpdateStatus. +func (m *MemberUpdateStatus) UnmarshalJSON(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 "clusterResourceId": + err = unpopulate(val, "ClusterResourceID", &m.ClusterResourceID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &m.OperationID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &m.Status) + 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateGroup. +func (u UpdateGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", u.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateGroup. +func (u *UpdateGroup) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &u.Name) + 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 UpdateGroupStatus. +func (u UpdateGroupStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "members", u.Members) + populate(objectMap, "name", u.Name) + populate(objectMap, "status", u.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateGroupStatus. +func (u *UpdateGroupStatus) UnmarshalJSON(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 "members": + err = unpopulate(val, "Members", &u.Members) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + 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 UpdateRun. +func (u UpdateRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", u.ETag) + populate(objectMap, "id", u.ID) + populate(objectMap, "name", u.Name) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "systemData", u.SystemData) + populate(objectMap, "type", u.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateRun. +func (u *UpdateRun) UnmarshalJSON(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 "eTag": + err = unpopulate(val, "ETag", &u.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &u.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &u.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &u.Type) + 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 UpdateRunListResult. +func (u UpdateRunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateRunListResult. +func (u *UpdateRunListResult) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &u.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &u.Value) + 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 UpdateRunProperties. +func (u UpdateRunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managedClusterUpdate", u.ManagedClusterUpdate) + populate(objectMap, "provisioningState", u.ProvisioningState) + populate(objectMap, "status", u.Status) + populate(objectMap, "strategy", u.Strategy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateRunProperties. +func (u *UpdateRunProperties) UnmarshalJSON(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 "managedClusterUpdate": + err = unpopulate(val, "ManagedClusterUpdate", &u.ManagedClusterUpdate) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &u.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + delete(rawMsg, key) + case "strategy": + err = unpopulate(val, "Strategy", &u.Strategy) + 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 UpdateRunStatus. +func (u UpdateRunStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "stages", u.Stages) + populate(objectMap, "status", u.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateRunStatus. +func (u *UpdateRunStatus) UnmarshalJSON(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 "stages": + err = unpopulate(val, "Stages", &u.Stages) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + 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 UpdateRunStrategy. +func (u UpdateRunStrategy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "stages", u.Stages) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateRunStrategy. +func (u *UpdateRunStrategy) UnmarshalJSON(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 "stages": + err = unpopulate(val, "Stages", &u.Stages) + 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 UpdateStage. +func (u UpdateStage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "afterStageWaitInSeconds", u.AfterStageWaitInSeconds) + populate(objectMap, "groups", u.Groups) + populate(objectMap, "name", u.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateStage. +func (u *UpdateStage) UnmarshalJSON(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 "afterStageWaitInSeconds": + err = unpopulate(val, "AfterStageWaitInSeconds", &u.AfterStageWaitInSeconds) + delete(rawMsg, key) + case "groups": + err = unpopulate(val, "Groups", &u.Groups) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + 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 UpdateStageStatus. +func (u UpdateStageStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "afterStageWaitStatus", u.AfterStageWaitStatus) + populate(objectMap, "groups", u.Groups) + populate(objectMap, "name", u.Name) + populate(objectMap, "status", u.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateStageStatus. +func (u *UpdateStageStatus) UnmarshalJSON(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 "afterStageWaitStatus": + err = unpopulate(val, "AfterStageWaitStatus", &u.AfterStageWaitStatus) + delete(rawMsg, key) + case "groups": + err = unpopulate(val, "Groups", &u.Groups) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + 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 UpdateStatus. +func (u UpdateStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "completedTime", u.CompletedTime) + populate(objectMap, "error", u.Error) + populateTimeRFC3339(objectMap, "startTime", u.StartTime) + populate(objectMap, "state", u.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateStatus. +func (u *UpdateStatus) UnmarshalJSON(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 "completedTime": + err = unpopulateTimeRFC3339(val, "CompletedTime", &u.CompletedTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &u.Error) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &u.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &u.State) + 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 WaitStatus. +func (w WaitStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "status", w.Status) + populate(objectMap, "waitDurationInSeconds", w.WaitDurationInSeconds) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WaitStatus. +func (w *WaitStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "status": + err = unpopulate(val, "Status", &w.Status) + delete(rawMsg, key) + case "waitDurationInSeconds": + err = unpopulate(val, "WaitDurationInSeconds", &w.WaitDurationInSeconds) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, 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 populateByteArray(m map[string]any, k string, b []byte, f runtime.Base64Encoding) { + if azcore.IsNullValue(b) { + m[k] = nil + } else if len(b) == 0 { + return + } else { + m[k] = runtime.EncodeByteArray(b, f) + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/operations_client.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/operations_client.go new file mode 100644 index 000000000000..820be2880d32 --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/operations_client.go @@ -0,0 +1,94 @@ +//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 + +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+".OperationsClient", 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-03-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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ContainerService/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-03-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/containerservice/armcontainerservicefleet/response_types.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/response_types.go new file mode 100644 index 000000000000..faebc02e932e --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/response_types.go @@ -0,0 +1,105 @@ +//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 + +// FleetMembersClientCreateResponse contains the response from method FleetMembersClient.BeginCreate. +type FleetMembersClientCreateResponse struct { + FleetMember +} + +// FleetMembersClientDeleteResponse contains the response from method FleetMembersClient.BeginDelete. +type FleetMembersClientDeleteResponse struct { + // placeholder for future response values +} + +// FleetMembersClientGetResponse contains the response from method FleetMembersClient.Get. +type FleetMembersClientGetResponse struct { + FleetMember +} + +// FleetMembersClientListByFleetResponse contains the response from method FleetMembersClient.NewListByFleetPager. +type FleetMembersClientListByFleetResponse struct { + FleetMemberListResult +} + +// FleetMembersClientUpdateResponse contains the response from method FleetMembersClient.Update. +type FleetMembersClientUpdateResponse struct { + FleetMember +} + +// FleetsClientCreateOrUpdateResponse contains the response from method FleetsClient.BeginCreateOrUpdate. +type FleetsClientCreateOrUpdateResponse struct { + Fleet +} + +// FleetsClientDeleteResponse contains the response from method FleetsClient.BeginDelete. +type FleetsClientDeleteResponse struct { + // placeholder for future response values +} + +// FleetsClientGetResponse contains the response from method FleetsClient.Get. +type FleetsClientGetResponse struct { + Fleet +} + +// FleetsClientListByResourceGroupResponse contains the response from method FleetsClient.NewListByResourceGroupPager. +type FleetsClientListByResourceGroupResponse struct { + FleetListResult +} + +// FleetsClientListBySubscriptionResponse contains the response from method FleetsClient.NewListBySubscriptionPager. +type FleetsClientListBySubscriptionResponse struct { + FleetListResult +} + +// FleetsClientListCredentialsResponse contains the response from method FleetsClient.ListCredentials. +type FleetsClientListCredentialsResponse struct { + FleetCredentialResults +} + +// FleetsClientUpdateResponse contains the response from method FleetsClient.Update. +type FleetsClientUpdateResponse struct { + Fleet +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + +// UpdateRunsClientCreateOrUpdateResponse contains the response from method UpdateRunsClient.BeginCreateOrUpdate. +type UpdateRunsClientCreateOrUpdateResponse struct { + UpdateRun +} + +// UpdateRunsClientDeleteResponse contains the response from method UpdateRunsClient.BeginDelete. +type UpdateRunsClientDeleteResponse struct { + // placeholder for future response values +} + +// UpdateRunsClientGetResponse contains the response from method UpdateRunsClient.Get. +type UpdateRunsClientGetResponse struct { + UpdateRun +} + +// UpdateRunsClientListByFleetResponse contains the response from method UpdateRunsClient.NewListByFleetPager. +type UpdateRunsClientListByFleetResponse struct { + UpdateRunListResult +} + +// UpdateRunsClientStartResponse contains the response from method UpdateRunsClient.BeginStart. +type UpdateRunsClientStartResponse struct { + UpdateRun +} + +// UpdateRunsClientStopResponse contains the response from method UpdateRunsClient.BeginStop. +type UpdateRunsClientStopResponse struct { + UpdateRun +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/time_rfc3339.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/time_rfc3339.go new file mode 100644 index 000000000000..41b18f78a91d --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/time_rfc3339.go @@ -0,0 +1,87 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]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] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/containerservice/armcontainerservicefleet/updateruns_client.go b/sdk/resourcemanager/containerservice/armcontainerservicefleet/updateruns_client.go new file mode 100644 index 000000000000..009fdb3cbb7e --- /dev/null +++ b/sdk/resourcemanager/containerservice/armcontainerservicefleet/updateruns_client.go @@ -0,0 +1,478 @@ +//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 + +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" +) + +// UpdateRunsClient contains the methods for the UpdateRuns group. +// Don't use this type directly, use NewUpdateRunsClient() instead. +type UpdateRunsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewUpdateRunsClient creates a new instance of UpdateRunsClient 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 NewUpdateRunsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UpdateRunsClient, error) { + cl, err := arm.NewClient(moduleName+".UpdateRunsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &UpdateRunsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a UpdateRun +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - updateRunName - The name of the UpdateRun resource. +// - resource - Resource create parameters. +// - options - UpdateRunsClientBeginCreateOrUpdateOptions contains the optional parameters for the UpdateRunsClient.BeginCreateOrUpdate +// method. +func (client *UpdateRunsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, resource UpdateRun, options *UpdateRunsClientBeginCreateOrUpdateOptions) (*runtime.Poller[UpdateRunsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, fleetName, updateRunName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UpdateRunsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[UpdateRunsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a UpdateRun +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *UpdateRunsClient) createOrUpdate(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, resource UpdateRun, options *UpdateRunsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, fleetName, updateRunName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *UpdateRunsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, resource UpdateRun, options *UpdateRunsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns/{updateRunName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if updateRunName == "" { + return nil, errors.New("parameter updateRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{updateRunName}", url.PathEscape(updateRunName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a UpdateRun +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - updateRunName - The name of the UpdateRun resource. +// - options - UpdateRunsClientBeginDeleteOptions contains the optional parameters for the UpdateRunsClient.BeginDelete method. +func (client *UpdateRunsClient) BeginDelete(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginDeleteOptions) (*runtime.Poller[UpdateRunsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UpdateRunsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[UpdateRunsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a UpdateRun +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *UpdateRunsClient) deleteOperation(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *UpdateRunsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns/{updateRunName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if updateRunName == "" { + return nil, errors.New("parameter updateRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{updateRunName}", url.PathEscape(updateRunName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a UpdateRun +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - updateRunName - The name of the UpdateRun resource. +// - options - UpdateRunsClientGetOptions contains the optional parameters for the UpdateRunsClient.Get method. +func (client *UpdateRunsClient) Get(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientGetOptions) (UpdateRunsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return UpdateRunsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return UpdateRunsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return UpdateRunsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *UpdateRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns/{updateRunName}" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if updateRunName == "" { + return nil, errors.New("parameter updateRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{updateRunName}", url.PathEscape(updateRunName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *UpdateRunsClient) getHandleResponse(resp *http.Response) (UpdateRunsClientGetResponse, error) { + result := UpdateRunsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.UpdateRun); err != nil { + return UpdateRunsClientGetResponse{}, err + } + return result, nil +} + +// NewListByFleetPager - List UpdateRun resources by Fleet +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - options - UpdateRunsClientListByFleetOptions contains the optional parameters for the UpdateRunsClient.NewListByFleetPager +// method. +func (client *UpdateRunsClient) NewListByFleetPager(resourceGroupName string, fleetName string, options *UpdateRunsClientListByFleetOptions) *runtime.Pager[UpdateRunsClientListByFleetResponse] { + return runtime.NewPager(runtime.PagingHandler[UpdateRunsClientListByFleetResponse]{ + More: func(page UpdateRunsClientListByFleetResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *UpdateRunsClientListByFleetResponse) (UpdateRunsClientListByFleetResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByFleetCreateRequest(ctx, resourceGroupName, fleetName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return UpdateRunsClientListByFleetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return UpdateRunsClientListByFleetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return UpdateRunsClientListByFleetResponse{}, runtime.NewResponseError(resp) + } + return client.listByFleetHandleResponse(resp) + }, + }) +} + +// listByFleetCreateRequest creates the ListByFleet request. +func (client *UpdateRunsClient) listByFleetCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, options *UpdateRunsClientListByFleetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByFleetHandleResponse handles the ListByFleet response. +func (client *UpdateRunsClient) listByFleetHandleResponse(resp *http.Response) (UpdateRunsClientListByFleetResponse, error) { + result := UpdateRunsClientListByFleetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.UpdateRunListResult); err != nil { + return UpdateRunsClientListByFleetResponse{}, err + } + return result, nil +} + +// BeginStart - Starts an UpdateRun. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - updateRunName - The name of the UpdateRun resource. +// - options - UpdateRunsClientBeginStartOptions contains the optional parameters for the UpdateRunsClient.BeginStart method. +func (client *UpdateRunsClient) BeginStart(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStartOptions) (*runtime.Poller[UpdateRunsClientStartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.start(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UpdateRunsClientStartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[UpdateRunsClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Start - Starts an UpdateRun. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *UpdateRunsClient) start(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *UpdateRunsClient) startCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns/{updateRunName}/start" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if updateRunName == "" { + return nil, errors.New("parameter updateRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{updateRunName}", url.PathEscape(updateRunName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginStop - Stops an UpdateRun. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fleetName - The name of the Fleet resource. +// - updateRunName - The name of the UpdateRun resource. +// - options - UpdateRunsClientBeginStopOptions contains the optional parameters for the UpdateRunsClient.BeginStop method. +func (client *UpdateRunsClient) BeginStop(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStopOptions) (*runtime.Poller[UpdateRunsClientStopResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.stop(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UpdateRunsClientStopResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[UpdateRunsClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Stop - Stops an UpdateRun. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-15-preview +func (client *UpdateRunsClient) stop(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStopOptions) (*http.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, fleetName, updateRunName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *UpdateRunsClient) stopCreateRequest(ctx context.Context, resourceGroupName string, fleetName string, updateRunName string, options *UpdateRunsClientBeginStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/updateRuns/{updateRunName}/stop" + 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 fleetName == "" { + return nil, errors.New("parameter fleetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fleetName}", url.PathEscape(fleetName)) + if updateRunName == "" { + return nil, errors.New("parameter updateRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{updateRunName}", url.PathEscape(updateRunName)) + 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-03-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +}