diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/CHANGELOG.md b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/CHANGELOG.md new file mode 100644 index 000000000000..1991d9c5f4d9 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0 (2024-10-10) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime` 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/kubernetesruntime/armkubernetesruntime/LICENSE.txt b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/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/kubernetesruntime/armkubernetesruntime/README.md b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/README.md new file mode 100644 index 000000000000..7168cbd88180 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/README.md @@ -0,0 +1,92 @@ +# Azure Kubernetesruntime Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime) + +The `armkubernetesruntime` module provides operations for working with Azure Kubernetesruntime. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime) + +# 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 Kubernetesruntime module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetesruntime. 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 Kubernetesruntime 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 := armkubernetesruntime.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armkubernetesruntime.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.() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Kubernetesruntime` 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/kubernetesruntime/armkubernetesruntime/autorest.md b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/autorest.md new file mode 100644 index 000000000000..58290ca0ef10 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/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/kubernetesruntime/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/kubernetesruntime/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 1.0.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/bgppeers_client.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/bgppeers_client.go new file mode 100644 index 000000000000..ed5d27a87369 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/bgppeers_client.go @@ -0,0 +1,271 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +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" +) + +// BgpPeersClient contains the methods for the BgpPeers group. +// Don't use this type directly, use NewBgpPeersClient() instead. +type BgpPeersClient struct { + internal *arm.Client +} + +// NewBgpPeersClient creates a new instance of BgpPeersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBgpPeersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BgpPeersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BgpPeersClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a BgpPeer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - bgpPeerName - The name of the BgpPeer +// - resource - Resource create parameters. +// - options - BgpPeersClientBeginCreateOrUpdateOptions contains the optional parameters for the BgpPeersClient.BeginCreateOrUpdate +// method. +func (client *BgpPeersClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, bgpPeerName string, resource BgpPeer, options *BgpPeersClientBeginCreateOrUpdateOptions) (*runtime.Poller[BgpPeersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, bgpPeerName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BgpPeersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BgpPeersClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a BgpPeer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *BgpPeersClient) createOrUpdate(ctx context.Context, resourceURI string, bgpPeerName string, resource BgpPeer, options *BgpPeersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "BgpPeersClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, bgpPeerName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *BgpPeersClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, bgpPeerName string, resource BgpPeer, options *BgpPeersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if bgpPeerName == "" { + return nil, errors.New("parameter bgpPeerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{bgpPeerName}", url.PathEscape(bgpPeerName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Delete a BgpPeer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - bgpPeerName - The name of the BgpPeer +// - options - BgpPeersClientDeleteOptions contains the optional parameters for the BgpPeersClient.Delete method. +func (client *BgpPeersClient) Delete(ctx context.Context, resourceURI string, bgpPeerName string, options *BgpPeersClientDeleteOptions) (BgpPeersClientDeleteResponse, error) { + var err error + const operationName = "BgpPeersClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceURI, bgpPeerName, options) + if err != nil { + return BgpPeersClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BgpPeersClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BgpPeersClientDeleteResponse{}, err + } + return BgpPeersClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *BgpPeersClient) deleteCreateRequest(ctx context.Context, resourceURI string, bgpPeerName string, options *BgpPeersClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if bgpPeerName == "" { + return nil, errors.New("parameter bgpPeerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{bgpPeerName}", url.PathEscape(bgpPeerName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a BgpPeer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - bgpPeerName - The name of the BgpPeer +// - options - BgpPeersClientGetOptions contains the optional parameters for the BgpPeersClient.Get method. +func (client *BgpPeersClient) Get(ctx context.Context, resourceURI string, bgpPeerName string, options *BgpPeersClientGetOptions) (BgpPeersClientGetResponse, error) { + var err error + const operationName = "BgpPeersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, bgpPeerName, options) + if err != nil { + return BgpPeersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BgpPeersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BgpPeersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BgpPeersClient) getCreateRequest(ctx context.Context, resourceURI string, bgpPeerName string, options *BgpPeersClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if bgpPeerName == "" { + return nil, errors.New("parameter bgpPeerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{bgpPeerName}", url.PathEscape(bgpPeerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BgpPeersClient) getHandleResponse(resp *http.Response) (BgpPeersClientGetResponse, error) { + result := BgpPeersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BgpPeer); err != nil { + return BgpPeersClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List BgpPeer resources by parent +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - BgpPeersClientListOptions contains the optional parameters for the BgpPeersClient.NewListPager method. +func (client *BgpPeersClient) NewListPager(resourceURI string, options *BgpPeersClientListOptions) *runtime.Pager[BgpPeersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[BgpPeersClientListResponse]{ + More: func(page BgpPeersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *BgpPeersClientListResponse) (BgpPeersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BgpPeersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return BgpPeersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *BgpPeersClient) listCreateRequest(ctx context.Context, resourceURI string, options *BgpPeersClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *BgpPeersClient) listHandleResponse(resp *http.Response) (BgpPeersClientListResponse, error) { + result := BgpPeersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BgpPeerListResult); err != nil { + return BgpPeersClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/build.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/build.go new file mode 100644 index 000000000000..67001290f241 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/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/kubernetesruntime/armkubernetesruntime + +package armkubernetesruntime diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/ci.yml b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/ci.yml new file mode 100644 index 000000000000..d57c4cc8d4cd --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/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/kubernetesruntime/armkubernetesruntime/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/kubernetesruntime/armkubernetesruntime' diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/client_factory.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/client_factory.go new file mode 100644 index 000000000000..cad29cb6c7a8 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/client_factory.go @@ -0,0 +1,69 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +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 { + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + internal: internal, + }, nil +} + +// NewBgpPeersClient creates a new instance of BgpPeersClient. +func (c *ClientFactory) NewBgpPeersClient() *BgpPeersClient { + return &BgpPeersClient{ + internal: c.internal, + } +} + +// NewLoadBalancersClient creates a new instance of LoadBalancersClient. +func (c *ClientFactory) NewLoadBalancersClient() *LoadBalancersClient { + return &LoadBalancersClient{ + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewServicesClient creates a new instance of ServicesClient. +func (c *ClientFactory) NewServicesClient() *ServicesClient { + return &ServicesClient{ + internal: c.internal, + } +} + +// NewStorageClassClient creates a new instance of StorageClassClient. +func (c *ClientFactory) NewStorageClassClient() *StorageClassClient { + return &StorageClassClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/constants.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/constants.go new file mode 100644 index 000000000000..9dde6bd2e528 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/constants.go @@ -0,0 +1,289 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + moduleVersion = "v1.0.0" +) + +// AccessMode - Storage Class Access Mode +type AccessMode string + +const ( + // AccessModeReadWriteMany - Read Write Many (RWX) access mode + AccessModeReadWriteMany AccessMode = "ReadWriteMany" + // AccessModeReadWriteOnce - Read Write Once (RWO) access mode + AccessModeReadWriteOnce AccessMode = "ReadWriteOnce" +) + +// PossibleAccessModeValues returns the possible values for the AccessMode const type. +func PossibleAccessModeValues() []AccessMode { + return []AccessMode{ + AccessModeReadWriteMany, + AccessModeReadWriteOnce, + } +} + +// 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, + } +} + +// AdvertiseMode - Enum of advertise mode +type AdvertiseMode string + +const ( + // AdvertiseModeARP - ARP advertise mode + AdvertiseModeARP AdvertiseMode = "ARP" + // AdvertiseModeBGP - BGP advertise mode + AdvertiseModeBGP AdvertiseMode = "BGP" + // AdvertiseModeBoth - both ARP and BGP advertise mode + AdvertiseModeBoth AdvertiseMode = "Both" +) + +// PossibleAdvertiseModeValues returns the possible values for the AdvertiseMode const type. +func PossibleAdvertiseModeValues() []AdvertiseMode { + return []AdvertiseMode{ + AdvertiseModeARP, + AdvertiseModeBGP, + AdvertiseModeBoth, + } +} + +// 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, + } +} + +// DataResilienceTier - Data resilience tier of a storage class +type DataResilienceTier string + +const ( + // DataResilienceTierDataResilient - Data resilient + DataResilienceTierDataResilient DataResilienceTier = "DataResilient" + // DataResilienceTierNotDataResilient - Not data resilient + DataResilienceTierNotDataResilient DataResilienceTier = "NotDataResilient" +) + +// PossibleDataResilienceTierValues returns the possible values for the DataResilienceTier const type. +func PossibleDataResilienceTierValues() []DataResilienceTier { + return []DataResilienceTier{ + DataResilienceTierDataResilient, + DataResilienceTierNotDataResilient, + } +} + +// FailoverTier - Failover tier of a storage class +type FailoverTier string + +const ( + // FailoverTierFast - Fast Failover Tier + FailoverTierFast FailoverTier = "Fast" + // FailoverTierNotAvailable - Not available Failover Tier + FailoverTierNotAvailable FailoverTier = "NotAvailable" + // FailoverTierSlow - Slow Failover Tier + FailoverTierSlow FailoverTier = "Slow" + // FailoverTierSuper - Super Failover Tier + FailoverTierSuper FailoverTier = "Super" +) + +// PossibleFailoverTierValues returns the possible values for the FailoverTier const type. +func PossibleFailoverTierValues() []FailoverTier { + return []FailoverTier{ + FailoverTierFast, + FailoverTierNotAvailable, + FailoverTierSlow, + FailoverTierSuper, + } +} + +// NfsDirectoryActionOnVolumeDeletion - The action to take when a NFS volume is deleted +type NfsDirectoryActionOnVolumeDeletion string + +const ( + // NfsDirectoryActionOnVolumeDeletionDelete - When the volume is deleted, delete the directory + NfsDirectoryActionOnVolumeDeletionDelete NfsDirectoryActionOnVolumeDeletion = "Delete" + // NfsDirectoryActionOnVolumeDeletionRetain - When the volume is deleted, retain the directory + NfsDirectoryActionOnVolumeDeletionRetain NfsDirectoryActionOnVolumeDeletion = "Retain" +) + +// PossibleNfsDirectoryActionOnVolumeDeletionValues returns the possible values for the NfsDirectoryActionOnVolumeDeletion const type. +func PossibleNfsDirectoryActionOnVolumeDeletionValues() []NfsDirectoryActionOnVolumeDeletion { + return []NfsDirectoryActionOnVolumeDeletion{ + NfsDirectoryActionOnVolumeDeletionDelete, + NfsDirectoryActionOnVolumeDeletionRetain, + } +} + +// 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, + } +} + +// PerformanceTier - Performance tier of a storage class +type PerformanceTier string + +const ( + // PerformanceTierBasic - Basic Performance Tier + PerformanceTierBasic PerformanceTier = "Basic" + // PerformanceTierPremium - Premium Performance Tier + PerformanceTierPremium PerformanceTier = "Premium" + // PerformanceTierStandard - Standard Performance Tier + PerformanceTierStandard PerformanceTier = "Standard" + // PerformanceTierUltra - Ultra Performance Tier + PerformanceTierUltra PerformanceTier = "Ultra" + // PerformanceTierUndefined - Undefined Performance Tier + PerformanceTierUndefined PerformanceTier = "Undefined" +) + +// PossiblePerformanceTierValues returns the possible values for the PerformanceTier const type. +func PossiblePerformanceTierValues() []PerformanceTier { + return []PerformanceTier{ + PerformanceTierBasic, + PerformanceTierPremium, + PerformanceTierStandard, + PerformanceTierUltra, + PerformanceTierUndefined, + } +} + +// ProvisioningState - The status of the current operation. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Change accepted for processing + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Deletion in progress + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Initial provisioning in progress + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Update in progress + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// SCType - Type of a storage class +type SCType string + +const ( + // SCTypeBlob - Blob storage class + SCTypeBlob SCType = "Blob" + // SCTypeNFS - NFS storage class + SCTypeNFS SCType = "NFS" + // SCTypeNative - Native storage class + SCTypeNative SCType = "Native" + // SCTypeRWX - RWX storage class + SCTypeRWX SCType = "RWX" + // SCTypeSMB - SMB storage class + SCTypeSMB SCType = "SMB" +) + +// PossibleSCTypeValues returns the possible values for the SCType const type. +func PossibleSCTypeValues() []SCType { + return []SCType{ + SCTypeBlob, + SCTypeNFS, + SCTypeNative, + SCTypeRWX, + SCTypeSMB, + } +} + +// VolumeBindingMode - Storage class volume binding mode +type VolumeBindingMode string + +const ( + // VolumeBindingModeImmediate - Immediate binding mode + VolumeBindingModeImmediate VolumeBindingMode = "Immediate" + // VolumeBindingModeWaitForFirstConsumer - Wait for first consumer binding mode + VolumeBindingModeWaitForFirstConsumer VolumeBindingMode = "WaitForFirstConsumer" +) + +// PossibleVolumeBindingModeValues returns the possible values for the VolumeBindingMode const type. +func PossibleVolumeBindingModeValues() []VolumeBindingMode { + return []VolumeBindingMode{ + VolumeBindingModeImmediate, + VolumeBindingModeWaitForFirstConsumer, + } +} + +// VolumeExpansion - Ability to expand volumes of a storage class +type VolumeExpansion string + +const ( + // VolumeExpansionAllow - Allow volume expansion + VolumeExpansionAllow VolumeExpansion = "Allow" + // VolumeExpansionDisallow - Disallow volume expansion + VolumeExpansionDisallow VolumeExpansion = "Disallow" +) + +// PossibleVolumeExpansionValues returns the possible values for the VolumeExpansion const type. +func PossibleVolumeExpansionValues() []VolumeExpansion { + return []VolumeExpansion{ + VolumeExpansionAllow, + VolumeExpansionDisallow, + } +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/bgppeers_server.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/bgppeers_server.go new file mode 100644 index 000000000000..ba2b58e5c02c --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/bgppeers_server.go @@ -0,0 +1,243 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + "net/http" + "net/url" + "regexp" +) + +// BgpPeersServer is a fake server for instances of the armkubernetesruntime.BgpPeersClient type. +type BgpPeersServer struct { + // BeginCreateOrUpdate is the fake for method BgpPeersClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceURI string, bgpPeerName string, resource armkubernetesruntime.BgpPeer, options *armkubernetesruntime.BgpPeersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkubernetesruntime.BgpPeersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BgpPeersClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceURI string, bgpPeerName string, options *armkubernetesruntime.BgpPeersClientDeleteOptions) (resp azfake.Responder[armkubernetesruntime.BgpPeersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BgpPeersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, bgpPeerName string, options *armkubernetesruntime.BgpPeersClientGetOptions) (resp azfake.Responder[armkubernetesruntime.BgpPeersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BgpPeersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armkubernetesruntime.BgpPeersClientListOptions) (resp azfake.PagerResponder[armkubernetesruntime.BgpPeersClientListResponse]) +} + +// NewBgpPeersServerTransport creates a new instance of BgpPeersServerTransport with the provided implementation. +// The returned BgpPeersServerTransport instance is connected to an instance of armkubernetesruntime.BgpPeersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBgpPeersServerTransport(srv *BgpPeersServer) *BgpPeersServerTransport { + return &BgpPeersServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkubernetesruntime.BgpPeersClientCreateOrUpdateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesruntime.BgpPeersClientListResponse]](), + } +} + +// BgpPeersServerTransport connects instances of armkubernetesruntime.BgpPeersClient to instances of BgpPeersServer. +// Don't use this type directly, use NewBgpPeersServerTransport instead. +type BgpPeersServerTransport struct { + srv *BgpPeersServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkubernetesruntime.BgpPeersClientCreateOrUpdateResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesruntime.BgpPeersClientListResponse]] +} + +// Do implements the policy.Transporter interface for BgpPeersServerTransport. +func (b *BgpPeersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BgpPeersClient.BeginCreateOrUpdate": + resp, err = b.dispatchBeginCreateOrUpdate(req) + case "BgpPeersClient.Delete": + resp, err = b.dispatchDelete(req) + case "BgpPeersClient.Get": + resp, err = b.dispatchGet(req) + case "BgpPeersClient.NewListPager": + resp, err = b.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BgpPeersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := b.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/bgpPeers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesruntime.BgpPeer](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + bgpPeerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("bgpPeerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginCreateOrUpdate(req.Context(), resourceURIParam, bgpPeerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + b.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + b.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + b.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (b *BgpPeersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/bgpPeers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + bgpPeerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("bgpPeerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), resourceURIParam, bgpPeerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BgpPeersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/bgpPeers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + bgpPeerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("bgpPeerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceURIParam, bgpPeerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BgpPeer, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BgpPeersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := b.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/bgpPeers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := b.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + b.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesruntime.BgpPeersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + b.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/internal.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/loadbalancers_server.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/loadbalancers_server.go new file mode 100644 index 000000000000..b1b98ff7239f --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/loadbalancers_server.go @@ -0,0 +1,243 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + "net/http" + "net/url" + "regexp" +) + +// LoadBalancersServer is a fake server for instances of the armkubernetesruntime.LoadBalancersClient type. +type LoadBalancersServer struct { + // BeginCreateOrUpdate is the fake for method LoadBalancersClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceURI string, loadBalancerName string, resource armkubernetesruntime.LoadBalancer, options *armkubernetesruntime.LoadBalancersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkubernetesruntime.LoadBalancersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method LoadBalancersClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceURI string, loadBalancerName string, options *armkubernetesruntime.LoadBalancersClientDeleteOptions) (resp azfake.Responder[armkubernetesruntime.LoadBalancersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method LoadBalancersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, loadBalancerName string, options *armkubernetesruntime.LoadBalancersClientGetOptions) (resp azfake.Responder[armkubernetesruntime.LoadBalancersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method LoadBalancersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armkubernetesruntime.LoadBalancersClientListOptions) (resp azfake.PagerResponder[armkubernetesruntime.LoadBalancersClientListResponse]) +} + +// NewLoadBalancersServerTransport creates a new instance of LoadBalancersServerTransport with the provided implementation. +// The returned LoadBalancersServerTransport instance is connected to an instance of armkubernetesruntime.LoadBalancersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLoadBalancersServerTransport(srv *LoadBalancersServer) *LoadBalancersServerTransport { + return &LoadBalancersServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkubernetesruntime.LoadBalancersClientCreateOrUpdateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesruntime.LoadBalancersClientListResponse]](), + } +} + +// LoadBalancersServerTransport connects instances of armkubernetesruntime.LoadBalancersClient to instances of LoadBalancersServer. +// Don't use this type directly, use NewLoadBalancersServerTransport instead. +type LoadBalancersServerTransport struct { + srv *LoadBalancersServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkubernetesruntime.LoadBalancersClientCreateOrUpdateResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesruntime.LoadBalancersClientListResponse]] +} + +// Do implements the policy.Transporter interface for LoadBalancersServerTransport. +func (l *LoadBalancersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "LoadBalancersClient.BeginCreateOrUpdate": + resp, err = l.dispatchBeginCreateOrUpdate(req) + case "LoadBalancersClient.Delete": + resp, err = l.dispatchDelete(req) + case "LoadBalancersClient.Get": + resp, err = l.dispatchGet(req) + case "LoadBalancersClient.NewListPager": + resp, err = l.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (l *LoadBalancersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if l.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := l.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/loadBalancers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesruntime.LoadBalancer](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginCreateOrUpdate(req.Context(), resourceURIParam, loadBalancerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + l.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + l.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + l.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (l *LoadBalancersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if l.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/loadBalancers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Delete(req.Context(), resourceURIParam, loadBalancerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LoadBalancersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if l.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/loadBalancers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + loadBalancerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadBalancerName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Get(req.Context(), resourceURIParam, loadBalancerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoadBalancer, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LoadBalancersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := l.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/loadBalancers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + l.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesruntime.LoadBalancersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + l.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/operations_server.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/operations_server.go new file mode 100644 index 000000000000..f62d71419651 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + "net/http" +) + +// OperationsServer is a fake server for instances of the armkubernetesruntime.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkubernetesruntime.OperationsClientListOptions) (resp azfake.PagerResponder[armkubernetesruntime.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armkubernetesruntime.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkubernetesruntime.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armkubernetesruntime.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armkubernetesruntime.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesruntime.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/server_factory.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/server_factory.go new file mode 100644 index 000000000000..50af3ffc79e0 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/server_factory.go @@ -0,0 +1,97 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armkubernetesruntime.ClientFactory type. +type ServerFactory struct { + BgpPeersServer BgpPeersServer + LoadBalancersServer LoadBalancersServer + OperationsServer OperationsServer + ServicesServer ServicesServer + StorageClassServer StorageClassServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armkubernetesruntime.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armkubernetesruntime.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trBgpPeersServer *BgpPeersServerTransport + trLoadBalancersServer *LoadBalancersServerTransport + trOperationsServer *OperationsServerTransport + trServicesServer *ServicesServerTransport + trStorageClassServer *StorageClassServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "BgpPeersClient": + initServer(s, &s.trBgpPeersServer, func() *BgpPeersServerTransport { return NewBgpPeersServerTransport(&s.srv.BgpPeersServer) }) + resp, err = s.trBgpPeersServer.Do(req) + case "LoadBalancersClient": + initServer(s, &s.trLoadBalancersServer, func() *LoadBalancersServerTransport { + return NewLoadBalancersServerTransport(&s.srv.LoadBalancersServer) + }) + resp, err = s.trLoadBalancersServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "ServicesClient": + initServer(s, &s.trServicesServer, func() *ServicesServerTransport { return NewServicesServerTransport(&s.srv.ServicesServer) }) + resp, err = s.trServicesServer.Do(req) + case "StorageClassClient": + initServer(s, &s.trStorageClassServer, func() *StorageClassServerTransport { return NewStorageClassServerTransport(&s.srv.StorageClassServer) }) + resp, err = s.trStorageClassServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/services_server.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/services_server.go new file mode 100644 index 000000000000..be1e67da2d01 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/services_server.go @@ -0,0 +1,230 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + "net/http" + "net/url" + "regexp" +) + +// ServicesServer is a fake server for instances of the armkubernetesruntime.ServicesClient type. +type ServicesServer struct { + // CreateOrUpdate is the fake for method ServicesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceURI string, serviceName string, resource armkubernetesruntime.ServiceResource, options *armkubernetesruntime.ServicesClientCreateOrUpdateOptions) (resp azfake.Responder[armkubernetesruntime.ServicesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ServicesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceURI string, serviceName string, options *armkubernetesruntime.ServicesClientDeleteOptions) (resp azfake.Responder[armkubernetesruntime.ServicesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ServicesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, serviceName string, options *armkubernetesruntime.ServicesClientGetOptions) (resp azfake.Responder[armkubernetesruntime.ServicesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ServicesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armkubernetesruntime.ServicesClientListOptions) (resp azfake.PagerResponder[armkubernetesruntime.ServicesClientListResponse]) +} + +// NewServicesServerTransport creates a new instance of ServicesServerTransport with the provided implementation. +// The returned ServicesServerTransport instance is connected to an instance of armkubernetesruntime.ServicesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServicesServerTransport(srv *ServicesServer) *ServicesServerTransport { + return &ServicesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkubernetesruntime.ServicesClientListResponse]](), + } +} + +// ServicesServerTransport connects instances of armkubernetesruntime.ServicesClient to instances of ServicesServer. +// Don't use this type directly, use NewServicesServerTransport instead. +type ServicesServerTransport struct { + srv *ServicesServer + newListPager *tracker[azfake.PagerResponder[armkubernetesruntime.ServicesClientListResponse]] +} + +// Do implements the policy.Transporter interface for ServicesServerTransport. +func (s *ServicesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ServicesClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "ServicesClient.Delete": + resp, err = s.dispatchDelete(req) + case "ServicesClient.Get": + resp, err = s.dispatchGet(req) + case "ServicesClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ServicesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/services/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesruntime.ServiceResource](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceURIParam, serviceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ServiceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServicesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/services/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceURIParam, serviceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServicesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/services/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceURIParam, serviceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ServiceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServicesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/services` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesruntime.ServicesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/storageclass_server.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/storageclass_server.go new file mode 100644 index 000000000000..6c804aa834f8 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/storageclass_server.go @@ -0,0 +1,312 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime" + "net/http" + "net/url" + "regexp" +) + +// StorageClassServer is a fake server for instances of the armkubernetesruntime.StorageClassClient type. +type StorageClassServer struct { + // BeginCreateOrUpdate is the fake for method StorageClassClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceURI string, storageClassName string, resource armkubernetesruntime.StorageClassResource, options *armkubernetesruntime.StorageClassClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkubernetesruntime.StorageClassClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method StorageClassClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceURI string, storageClassName string, options *armkubernetesruntime.StorageClassClientBeginDeleteOptions) (resp azfake.PollerResponder[armkubernetesruntime.StorageClassClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method StorageClassClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, storageClassName string, options *armkubernetesruntime.StorageClassClientGetOptions) (resp azfake.Responder[armkubernetesruntime.StorageClassClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method StorageClassClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armkubernetesruntime.StorageClassClientListOptions) (resp azfake.PagerResponder[armkubernetesruntime.StorageClassClientListResponse]) + + // BeginUpdate is the fake for method StorageClassClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceURI string, storageClassName string, properties armkubernetesruntime.StorageClassResourceUpdate, options *armkubernetesruntime.StorageClassClientBeginUpdateOptions) (resp azfake.PollerResponder[armkubernetesruntime.StorageClassClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewStorageClassServerTransport creates a new instance of StorageClassServerTransport with the provided implementation. +// The returned StorageClassServerTransport instance is connected to an instance of armkubernetesruntime.StorageClassClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewStorageClassServerTransport(srv *StorageClassServer) *StorageClassServerTransport { + return &StorageClassServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesruntime.StorageClassClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientUpdateResponse]](), + } +} + +// StorageClassServerTransport connects instances of armkubernetesruntime.StorageClassClient to instances of StorageClassServer. +// Don't use this type directly, use NewStorageClassServerTransport instead. +type StorageClassServerTransport struct { + srv *StorageClassServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesruntime.StorageClassClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkubernetesruntime.StorageClassClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for StorageClassServerTransport. +func (s *StorageClassServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "StorageClassClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "StorageClassClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "StorageClassClient.Get": + resp, err = s.dispatchGet(req) + case "StorageClassClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + case "StorageClassClient.BeginUpdate": + resp, err = s.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *StorageClassServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/storageClasses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesruntime.StorageClassResource](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + storageClassNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageClassName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceURIParam, storageClassNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *StorageClassServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/storageClasses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + storageClassNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageClassName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceURIParam, storageClassNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *StorageClassServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/storageClasses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + storageClassNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageClassName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceURIParam, storageClassNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).StorageClassResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *StorageClassServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/storageClasses` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesruntime.StorageClassClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} + +func (s *StorageClassServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesRuntime/storageClasses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesruntime.StorageClassResourceUpdate](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + storageClassNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageClassName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceURIParam, storageClassNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/time_rfc3339.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.mod b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.mod new file mode 100644 index 000000000000..b0ef5fd99181 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.sum b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.sum new file mode 100644 index 000000000000..03ce617a1873 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/interfaces.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/interfaces.go new file mode 100644 index 000000000000..ae91ece32961 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/interfaces.go @@ -0,0 +1,19 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +// StorageClassTypePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetStorageClassTypeProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BlobStorageClassTypeProperties, *NativeStorageClassTypeProperties, *NfsStorageClassTypeProperties, *RwxStorageClassTypeProperties, +// - *SmbStorageClassTypeProperties, *StorageClassTypeProperties +type StorageClassTypePropertiesClassification interface { + // GetStorageClassTypeProperties returns the StorageClassTypeProperties content of the underlying type. + GetStorageClassTypeProperties() *StorageClassTypeProperties +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/loadbalancers_client.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/loadbalancers_client.go new file mode 100644 index 000000000000..6d839e15a3f6 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/loadbalancers_client.go @@ -0,0 +1,271 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +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" +) + +// LoadBalancersClient contains the methods for the LoadBalancers group. +// Don't use this type directly, use NewLoadBalancersClient() instead. +type LoadBalancersClient struct { + internal *arm.Client +} + +// NewLoadBalancersClient creates a new instance of LoadBalancersClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewLoadBalancersClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LoadBalancersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &LoadBalancersClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a LoadBalancer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - loadBalancerName - The name of the LoadBalancer +// - resource - Resource create parameters. +// - options - LoadBalancersClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadBalancersClient.BeginCreateOrUpdate +// method. +func (client *LoadBalancersClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, loadBalancerName string, resource LoadBalancer, options *LoadBalancersClientBeginCreateOrUpdateOptions) (*runtime.Poller[LoadBalancersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, loadBalancerName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadBalancersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadBalancersClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a LoadBalancer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *LoadBalancersClient) createOrUpdate(ctx context.Context, resourceURI string, loadBalancerName string, resource LoadBalancer, options *LoadBalancersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "LoadBalancersClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, loadBalancerName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LoadBalancersClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, loadBalancerName string, resource LoadBalancer, options *LoadBalancersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if loadBalancerName == "" { + return nil, errors.New("parameter loadBalancerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadBalancerName}", url.PathEscape(loadBalancerName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Delete a LoadBalancer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - loadBalancerName - The name of the LoadBalancer +// - options - LoadBalancersClientDeleteOptions contains the optional parameters for the LoadBalancersClient.Delete method. +func (client *LoadBalancersClient) Delete(ctx context.Context, resourceURI string, loadBalancerName string, options *LoadBalancersClientDeleteOptions) (LoadBalancersClientDeleteResponse, error) { + var err error + const operationName = "LoadBalancersClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceURI, loadBalancerName, options) + if err != nil { + return LoadBalancersClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LoadBalancersClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return LoadBalancersClientDeleteResponse{}, err + } + return LoadBalancersClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LoadBalancersClient) deleteCreateRequest(ctx context.Context, resourceURI string, loadBalancerName string, options *LoadBalancersClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if loadBalancerName == "" { + return nil, errors.New("parameter loadBalancerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadBalancerName}", url.PathEscape(loadBalancerName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a LoadBalancer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - loadBalancerName - The name of the LoadBalancer +// - options - LoadBalancersClientGetOptions contains the optional parameters for the LoadBalancersClient.Get method. +func (client *LoadBalancersClient) Get(ctx context.Context, resourceURI string, loadBalancerName string, options *LoadBalancersClientGetOptions) (LoadBalancersClientGetResponse, error) { + var err error + const operationName = "LoadBalancersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, loadBalancerName, options) + if err != nil { + return LoadBalancersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LoadBalancersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LoadBalancersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *LoadBalancersClient) getCreateRequest(ctx context.Context, resourceURI string, loadBalancerName string, options *LoadBalancersClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if loadBalancerName == "" { + return nil, errors.New("parameter loadBalancerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadBalancerName}", url.PathEscape(loadBalancerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LoadBalancersClient) getHandleResponse(resp *http.Response) (LoadBalancersClientGetResponse, error) { + result := LoadBalancersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoadBalancer); err != nil { + return LoadBalancersClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List LoadBalancer resources by parent +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - LoadBalancersClientListOptions contains the optional parameters for the LoadBalancersClient.NewListPager method. +func (client *LoadBalancersClient) NewListPager(resourceURI string, options *LoadBalancersClientListOptions) *runtime.Pager[LoadBalancersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadBalancersClientListResponse]{ + More: func(page LoadBalancersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadBalancersClientListResponse) (LoadBalancersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadBalancersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return LoadBalancersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *LoadBalancersClient) listCreateRequest(ctx context.Context, resourceURI string, options *LoadBalancersClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LoadBalancersClient) listHandleResponse(resp *http.Response) (LoadBalancersClientListResponse, error) { + result := LoadBalancersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoadBalancerListResult); err != nil { + return LoadBalancersClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models.go new file mode 100644 index 000000000000..5804f1240d8e --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models.go @@ -0,0 +1,461 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +import "time" + +// BgpPeer - A BgpPeer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) +type BgpPeer struct { + // The resource-specific properties for this resource. + Properties *BgpPeerProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// BgpPeerListResult - The response of a BgpPeer list operation. +type BgpPeerListResult struct { + // REQUIRED; The BgpPeer items on this page + Value []*BgpPeer + + // The link to the next page of items + NextLink *string +} + +// BgpPeerProperties - Details of the BgpPeer. +type BgpPeerProperties struct { + // REQUIRED; My ASN + MyAsn *int32 + + // REQUIRED; Peer Address + PeerAddress *string + + // REQUIRED; Peer ASN + PeerAsn *int32 + + // READ-ONLY; Resource provision state + ProvisioningState *ProvisioningState +} + +// BlobStorageClassTypeProperties - The properties of Blob StorageClass +type BlobStorageClassTypeProperties struct { + // REQUIRED; Azure Storage Account Key + AzureStorageAccountKey *string + + // REQUIRED; Azure Storage Account Name + AzureStorageAccountName *string + + // REQUIRED; Type of the storage class. + Type *SCType +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type BlobStorageClassTypeProperties. +func (b *BlobStorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return &StorageClassTypeProperties{ + Type: b.Type, + } +} + +// LoadBalancer - A LoadBalancer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) +type LoadBalancer struct { + // The resource-specific properties for this resource. + Properties *LoadBalancerProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// LoadBalancerListResult - The response of a LoadBalancer list operation. +type LoadBalancerListResult struct { + // REQUIRED; The LoadBalancer items on this page + Value []*LoadBalancer + + // The link to the next page of items + NextLink *string +} + +// LoadBalancerProperties - Details of the LoadBalancer. +type LoadBalancerProperties struct { + // REQUIRED; IP Range + Addresses []*string + + // REQUIRED; Advertise Mode + AdvertiseMode *AdvertiseMode + + // The list of BGP peers it should advertise to. Null or empty means to advertise to all peers. + BgpPeers []*string + + // A dynamic label mapping to select related services. For instance, if you want to create a load balancer only for services + // with label "a=b", then please specify {"a": "b"} in the field. + ServiceSelector map[string]*string + + // READ-ONLY; Resource provision state + ProvisioningState *ProvisioningState +} + +// NativeStorageClassTypeProperties - The properties of Native StorageClass +type NativeStorageClassTypeProperties struct { + // REQUIRED; Type of the storage class. + Type *SCType +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type NativeStorageClassTypeProperties. +func (n *NativeStorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return &StorageClassTypeProperties{ + Type: n.Type, + } +} + +// NfsStorageClassTypeProperties - The properties of NFS StorageClass +type NfsStorageClassTypeProperties struct { + // REQUIRED; NFS Server + Server *string + + // REQUIRED; NFS share + Share *string + + // REQUIRED; Type of the storage class. + Type *SCType + + // Mounted folder permissions. Default is 0. If set as non-zero, driver will perform chmod after mount + MountPermissions *string + + // The action to take when a NFS volume is deleted. Default is Delete + OnDelete *NfsDirectoryActionOnVolumeDeletion + + // Sub directory under share. If the sub directory doesn't exist, driver will create it + SubDir *string +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type NfsStorageClassTypeProperties. +func (n *NfsStorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return &StorageClassTypeProperties{ + Type: n.Type, + } +} + +// 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 +} + +// RwxStorageClassTypeProperties - The properties of RWX StorageClass +type RwxStorageClassTypeProperties struct { + // REQUIRED; The backing storageclass used to create new storageclass + BackingStorageClassName *string + + // REQUIRED; Type of the storage class. + Type *SCType +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type RwxStorageClassTypeProperties. +func (r *RwxStorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return &StorageClassTypeProperties{ + Type: r.Type, + } +} + +// ServiceProperties - Properties for the service resource +type ServiceProperties struct { + // READ-ONLY; Resource provision state + ProvisioningState *ProvisioningState + + // READ-ONLY; The object id of the service principal of the RP provisioned in the tenant + RpObjectID *string +} + +// ServiceResource - A Service resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) +type ServiceResource struct { + // The resource-specific properties for this resource. + Properties *ServiceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ServiceResourceListResult - The response of a ServiceResource list operation. +type ServiceResourceListResult struct { + // REQUIRED; The ServiceResource items on this page + Value []*ServiceResource + + // The link to the next page of items + NextLink *string +} + +// SmbStorageClassTypeProperties - The properties of SMB StorageClass +type SmbStorageClassTypeProperties struct { + // REQUIRED; SMB Source + Source *string + + // REQUIRED; Type of the storage class. + Type *SCType + + // Server domain + Domain *string + + // Server password + Password *string + + // Sub directory under share. If the sub directory doesn't exist, driver will create it + SubDir *string + + // Server username + Username *string +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type SmbStorageClassTypeProperties. +func (s *SmbStorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return &StorageClassTypeProperties{ + Type: s.Type, + } +} + +// StorageClassProperties - Details of the StorageClass StorageClass. +type StorageClassProperties struct { + // REQUIRED; Properties of the StorageClass + TypeProperties StorageClassTypePropertiesClassification + + // The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce] + AccessModes []*AccessMode + + // Volume can be expanded or not + AllowVolumeExpansion *VolumeExpansion + + // Allow single data node failure + DataResilience *DataResilienceTier + + // Failover speed: NA, Slow, Fast + FailoverSpeed *FailoverTier + + // Limitations of the storage class + Limitations []*string + + // Additional mount options + MountOptions []*string + + // Performance tier + Performance *PerformanceTier + + // Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use + Priority *int64 + + // Provisioner name + Provisioner *string + + // Binding mode of volumes: Immediate, WaitForFirstConsumer + VolumeBindingMode *VolumeBindingMode + + // READ-ONLY; Resource provision state + ProvisioningState *ProvisioningState +} + +// StorageClassPropertiesUpdate - The model for updating storageClass properties +type StorageClassPropertiesUpdate struct { + // The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce] + AccessModes []*AccessMode + + // Volume can be expanded or not + AllowVolumeExpansion *VolumeExpansion + + // Allow single data node failure + DataResilience *DataResilienceTier + + // Failover speed: NA, Slow, Fast + FailoverSpeed *FailoverTier + + // Limitations of the storage class + Limitations []*string + + // Additional mount options + MountOptions []*string + + // Performance tier + Performance *PerformanceTier + + // Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use + Priority *int64 + + // New storage class type of storageClass + TypeProperties *StorageClassTypePropertiesUpdate +} + +// StorageClassResource - A StorageClass resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) +type StorageClassResource struct { + // The resource-specific properties for this resource. + Properties *StorageClassProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// StorageClassResourceListResult - The response of a StorageClassResource list operation. +type StorageClassResourceListResult struct { + // REQUIRED; The StorageClassResource items on this page + Value []*StorageClassResource + + // The link to the next page of items + NextLink *string +} + +// StorageClassResourceUpdate - The model for updating a storageClass +type StorageClassResourceUpdate struct { + // The properties of StorageClass + Properties *StorageClassPropertiesUpdate +} + +// StorageClassTypeProperties - The properties of storage class of the StorageClass +type StorageClassTypeProperties struct { + // REQUIRED; Type of the storage class. + Type *SCType +} + +// GetStorageClassTypeProperties implements the StorageClassTypePropertiesClassification interface for type StorageClassTypeProperties. +func (s *StorageClassTypeProperties) GetStorageClassTypeProperties() *StorageClassTypeProperties { + return s +} + +// StorageClassTypePropertiesUpdate - The model for update a storageClass +type StorageClassTypePropertiesUpdate struct { + // Azure Storage Account Key + AzureStorageAccountKey *string + + // Azure Storage Account Name + AzureStorageAccountName *string + + // The backing storageclass used to create new storageclass + BackingStorageClassName *string + + // Server domain + Domain *string + + // Mounted folder permissions. Default is 0. If set as non-zero, driver will perform chmod after mount + MountPermissions *string + + // The action to take when a NFS volume is deleted. Default is Delete + OnDelete *NfsDirectoryActionOnVolumeDeletion + + // Server password + Password *string + + // NFS Server + Server *string + + // NFS share + Share *string + + // SMB Source + Source *string + + // Sub directory under share. If the sub directory doesn't exist, driver will create it + SubDir *string + + // Server username + Username *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models_serde.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models_serde.go new file mode 100644 index 000000000000..1754ee97b079 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/models_serde.go @@ -0,0 +1,1047 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type BgpPeer. +func (b BgpPeer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "systemData", b.SystemData) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BgpPeer. +func (b *BgpPeer) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BgpPeerListResult. +func (b BgpPeerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BgpPeerListResult. +func (b *BgpPeerListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BgpPeerProperties. +func (b BgpPeerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "myAsn", b.MyAsn) + populate(objectMap, "peerAddress", b.PeerAddress) + populate(objectMap, "peerAsn", b.PeerAsn) + populate(objectMap, "provisioningState", b.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BgpPeerProperties. +func (b *BgpPeerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "myAsn": + err = unpopulate(val, "MyAsn", &b.MyAsn) + delete(rawMsg, key) + case "peerAddress": + err = unpopulate(val, "PeerAddress", &b.PeerAddress) + delete(rawMsg, key) + case "peerAsn": + err = unpopulate(val, "PeerAsn", &b.PeerAsn) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &b.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BlobStorageClassTypeProperties. +func (b BlobStorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureStorageAccountKey", b.AzureStorageAccountKey) + populate(objectMap, "azureStorageAccountName", b.AzureStorageAccountName) + objectMap["type"] = SCTypeBlob + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BlobStorageClassTypeProperties. +func (b *BlobStorageClassTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureStorageAccountKey": + err = unpopulate(val, "AzureStorageAccountKey", &b.AzureStorageAccountKey) + delete(rawMsg, key) + case "azureStorageAccountName": + err = unpopulate(val, "AzureStorageAccountName", &b.AzureStorageAccountName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancer. +func (l LoadBalancer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancer. +func (l *LoadBalancer) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancerListResult. +func (l LoadBalancerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancerListResult. +func (l *LoadBalancerListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancerProperties. +func (l LoadBalancerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addresses", l.Addresses) + populate(objectMap, "advertiseMode", l.AdvertiseMode) + populate(objectMap, "bgpPeers", l.BgpPeers) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "serviceSelector", l.ServiceSelector) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancerProperties. +func (l *LoadBalancerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addresses": + err = unpopulate(val, "Addresses", &l.Addresses) + delete(rawMsg, key) + case "advertiseMode": + err = unpopulate(val, "AdvertiseMode", &l.AdvertiseMode) + delete(rawMsg, key) + case "bgpPeers": + err = unpopulate(val, "BgpPeers", &l.BgpPeers) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "serviceSelector": + err = unpopulate(val, "ServiceSelector", &l.ServiceSelector) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NativeStorageClassTypeProperties. +func (n NativeStorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = SCTypeNative + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NativeStorageClassTypeProperties. +func (n *NativeStorageClassTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NfsStorageClassTypeProperties. +func (n NfsStorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mountPermissions", n.MountPermissions) + populate(objectMap, "onDelete", n.OnDelete) + populate(objectMap, "server", n.Server) + populate(objectMap, "share", n.Share) + populate(objectMap, "subDir", n.SubDir) + objectMap["type"] = SCTypeNFS + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NfsStorageClassTypeProperties. +func (n *NfsStorageClassTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mountPermissions": + err = unpopulate(val, "MountPermissions", &n.MountPermissions) + delete(rawMsg, key) + case "onDelete": + err = unpopulate(val, "OnDelete", &n.OnDelete) + delete(rawMsg, key) + case "server": + err = unpopulate(val, "Server", &n.Server) + delete(rawMsg, key) + case "share": + err = unpopulate(val, "Share", &n.Share) + delete(rawMsg, key) + case "subDir": + err = unpopulate(val, "SubDir", &n.SubDir) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, 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 RwxStorageClassTypeProperties. +func (r RwxStorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backingStorageClassName", r.BackingStorageClassName) + objectMap["type"] = SCTypeRWX + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RwxStorageClassTypeProperties. +func (r *RwxStorageClassTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backingStorageClassName": + err = unpopulate(val, "BackingStorageClassName", &r.BackingStorageClassName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceProperties. +func (s ServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "rpObjectId", s.RpObjectID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceProperties. +func (s *ServiceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "rpObjectId": + err = unpopulate(val, "RpObjectID", &s.RpObjectID) + 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 ServiceResource. +func (s ServiceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceResource. +func (s *ServiceResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceResourceListResult. +func (s ServiceResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceResourceListResult. +func (s *ServiceResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SmbStorageClassTypeProperties. +func (s SmbStorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "domain", s.Domain) + populate(objectMap, "password", s.Password) + populate(objectMap, "source", s.Source) + populate(objectMap, "subDir", s.SubDir) + objectMap["type"] = SCTypeSMB + populate(objectMap, "username", s.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SmbStorageClassTypeProperties. +func (s *SmbStorageClassTypeProperties) UnmarshalJSON(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 "domain": + err = unpopulate(val, "Domain", &s.Domain) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &s.Password) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &s.Source) + delete(rawMsg, key) + case "subDir": + err = unpopulate(val, "SubDir", &s.SubDir) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &s.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageClassProperties. +func (s StorageClassProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessModes", s.AccessModes) + populate(objectMap, "allowVolumeExpansion", s.AllowVolumeExpansion) + populate(objectMap, "dataResilience", s.DataResilience) + populate(objectMap, "failoverSpeed", s.FailoverSpeed) + populate(objectMap, "limitations", s.Limitations) + populate(objectMap, "mountOptions", s.MountOptions) + populate(objectMap, "performance", s.Performance) + populate(objectMap, "priority", s.Priority) + populate(objectMap, "provisioner", s.Provisioner) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "typeProperties", s.TypeProperties) + populate(objectMap, "volumeBindingMode", s.VolumeBindingMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassProperties. +func (s *StorageClassProperties) UnmarshalJSON(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 "accessModes": + err = unpopulate(val, "AccessModes", &s.AccessModes) + delete(rawMsg, key) + case "allowVolumeExpansion": + err = unpopulate(val, "AllowVolumeExpansion", &s.AllowVolumeExpansion) + delete(rawMsg, key) + case "dataResilience": + err = unpopulate(val, "DataResilience", &s.DataResilience) + delete(rawMsg, key) + case "failoverSpeed": + err = unpopulate(val, "FailoverSpeed", &s.FailoverSpeed) + delete(rawMsg, key) + case "limitations": + err = unpopulate(val, "Limitations", &s.Limitations) + delete(rawMsg, key) + case "mountOptions": + err = unpopulate(val, "MountOptions", &s.MountOptions) + delete(rawMsg, key) + case "performance": + err = unpopulate(val, "Performance", &s.Performance) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &s.Priority) + delete(rawMsg, key) + case "provisioner": + err = unpopulate(val, "Provisioner", &s.Provisioner) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "typeProperties": + s.TypeProperties, err = unmarshalStorageClassTypePropertiesClassification(val) + delete(rawMsg, key) + case "volumeBindingMode": + err = unpopulate(val, "VolumeBindingMode", &s.VolumeBindingMode) + 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 StorageClassPropertiesUpdate. +func (s StorageClassPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessModes", s.AccessModes) + populate(objectMap, "allowVolumeExpansion", s.AllowVolumeExpansion) + populate(objectMap, "dataResilience", s.DataResilience) + populate(objectMap, "failoverSpeed", s.FailoverSpeed) + populate(objectMap, "limitations", s.Limitations) + populate(objectMap, "mountOptions", s.MountOptions) + populate(objectMap, "performance", s.Performance) + populate(objectMap, "priority", s.Priority) + populate(objectMap, "typeProperties", s.TypeProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassPropertiesUpdate. +func (s *StorageClassPropertiesUpdate) UnmarshalJSON(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 "accessModes": + err = unpopulate(val, "AccessModes", &s.AccessModes) + delete(rawMsg, key) + case "allowVolumeExpansion": + err = unpopulate(val, "AllowVolumeExpansion", &s.AllowVolumeExpansion) + delete(rawMsg, key) + case "dataResilience": + err = unpopulate(val, "DataResilience", &s.DataResilience) + delete(rawMsg, key) + case "failoverSpeed": + err = unpopulate(val, "FailoverSpeed", &s.FailoverSpeed) + delete(rawMsg, key) + case "limitations": + err = unpopulate(val, "Limitations", &s.Limitations) + delete(rawMsg, key) + case "mountOptions": + err = unpopulate(val, "MountOptions", &s.MountOptions) + delete(rawMsg, key) + case "performance": + err = unpopulate(val, "Performance", &s.Performance) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &s.Priority) + delete(rawMsg, key) + case "typeProperties": + err = unpopulate(val, "TypeProperties", &s.TypeProperties) + 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 StorageClassResource. +func (s StorageClassResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassResource. +func (s *StorageClassResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageClassResourceListResult. +func (s StorageClassResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassResourceListResult. +func (s *StorageClassResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageClassResourceUpdate. +func (s StorageClassResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassResourceUpdate. +func (s *StorageClassResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageClassTypeProperties. +func (s StorageClassTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = s.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassTypeProperties. +func (s *StorageClassTypeProperties) UnmarshalJSON(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 "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageClassTypePropertiesUpdate. +func (s StorageClassTypePropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureStorageAccountKey", s.AzureStorageAccountKey) + populate(objectMap, "azureStorageAccountName", s.AzureStorageAccountName) + populate(objectMap, "backingStorageClassName", s.BackingStorageClassName) + populate(objectMap, "domain", s.Domain) + populate(objectMap, "mountPermissions", s.MountPermissions) + populate(objectMap, "onDelete", s.OnDelete) + populate(objectMap, "password", s.Password) + populate(objectMap, "server", s.Server) + populate(objectMap, "share", s.Share) + populate(objectMap, "source", s.Source) + populate(objectMap, "subDir", s.SubDir) + populate(objectMap, "username", s.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageClassTypePropertiesUpdate. +func (s *StorageClassTypePropertiesUpdate) UnmarshalJSON(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 "azureStorageAccountKey": + err = unpopulate(val, "AzureStorageAccountKey", &s.AzureStorageAccountKey) + delete(rawMsg, key) + case "azureStorageAccountName": + err = unpopulate(val, "AzureStorageAccountName", &s.AzureStorageAccountName) + delete(rawMsg, key) + case "backingStorageClassName": + err = unpopulate(val, "BackingStorageClassName", &s.BackingStorageClassName) + delete(rawMsg, key) + case "domain": + err = unpopulate(val, "Domain", &s.Domain) + delete(rawMsg, key) + case "mountPermissions": + err = unpopulate(val, "MountPermissions", &s.MountPermissions) + delete(rawMsg, key) + case "onDelete": + err = unpopulate(val, "OnDelete", &s.OnDelete) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &s.Password) + delete(rawMsg, key) + case "server": + err = unpopulate(val, "Server", &s.Server) + delete(rawMsg, key) + case "share": + err = unpopulate(val, "Share", &s.Share) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &s.Source) + delete(rawMsg, key) + case "subDir": + err = unpopulate(val, "SubDir", &s.SubDir) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &s.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/operations_client.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/operations_client.go new file mode 100644 index 000000000000..22f0f7b22691 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2024-03-01 +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.KubernetesRuntime/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/options.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/options.go new file mode 100644 index 000000000000..f5c0b76a483c --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/options.go @@ -0,0 +1,106 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +// BgpPeersClientBeginCreateOrUpdateOptions contains the optional parameters for the BgpPeersClient.BeginCreateOrUpdate method. +type BgpPeersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BgpPeersClientDeleteOptions contains the optional parameters for the BgpPeersClient.Delete method. +type BgpPeersClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// BgpPeersClientGetOptions contains the optional parameters for the BgpPeersClient.Get method. +type BgpPeersClientGetOptions struct { + // placeholder for future optional parameters +} + +// BgpPeersClientListOptions contains the optional parameters for the BgpPeersClient.NewListPager method. +type BgpPeersClientListOptions struct { + // placeholder for future optional parameters +} + +// LoadBalancersClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadBalancersClient.BeginCreateOrUpdate +// method. +type LoadBalancersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LoadBalancersClientDeleteOptions contains the optional parameters for the LoadBalancersClient.Delete method. +type LoadBalancersClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// LoadBalancersClientGetOptions contains the optional parameters for the LoadBalancersClient.Get method. +type LoadBalancersClientGetOptions struct { + // placeholder for future optional parameters +} + +// LoadBalancersClientListOptions contains the optional parameters for the LoadBalancersClient.NewListPager method. +type LoadBalancersClientListOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ServicesClientCreateOrUpdateOptions contains the optional parameters for the ServicesClient.CreateOrUpdate method. +type ServicesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ServicesClientDeleteOptions contains the optional parameters for the ServicesClient.Delete method. +type ServicesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. +type ServicesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. +type ServicesClientListOptions struct { + // placeholder for future optional parameters +} + +// StorageClassClientBeginCreateOrUpdateOptions contains the optional parameters for the StorageClassClient.BeginCreateOrUpdate +// method. +type StorageClassClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageClassClientBeginDeleteOptions contains the optional parameters for the StorageClassClient.BeginDelete method. +type StorageClassClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageClassClientBeginUpdateOptions contains the optional parameters for the StorageClassClient.BeginUpdate method. +type StorageClassClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageClassClientGetOptions contains the optional parameters for the StorageClassClient.Get method. +type StorageClassClientGetOptions struct { + // placeholder for future optional parameters +} + +// StorageClassClientListOptions contains the optional parameters for the StorageClassClient.NewListPager method. +type StorageClassClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/polymorphic_helpers.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/polymorphic_helpers.go new file mode 100644 index 000000000000..c36b9eecc969 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/polymorphic_helpers.go @@ -0,0 +1,40 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +import "encoding/json" + +func unmarshalStorageClassTypePropertiesClassification(rawMsg json.RawMessage) (StorageClassTypePropertiesClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b StorageClassTypePropertiesClassification + switch m["type"] { + case string(SCTypeBlob): + b = &BlobStorageClassTypeProperties{} + case string(SCTypeNFS): + b = &NfsStorageClassTypeProperties{} + case string(SCTypeNative): + b = &NativeStorageClassTypeProperties{} + case string(SCTypeRWX): + b = &RwxStorageClassTypeProperties{} + case string(SCTypeSMB): + b = &SmbStorageClassTypeProperties{} + default: + b = &StorageClassTypeProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/responses.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/responses.go new file mode 100644 index 000000000000..1612a9bda85f --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/responses.go @@ -0,0 +1,113 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +// BgpPeersClientCreateOrUpdateResponse contains the response from method BgpPeersClient.BeginCreateOrUpdate. +type BgpPeersClientCreateOrUpdateResponse struct { + // A BgpPeer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + BgpPeer +} + +// BgpPeersClientDeleteResponse contains the response from method BgpPeersClient.Delete. +type BgpPeersClientDeleteResponse struct { + // placeholder for future response values +} + +// BgpPeersClientGetResponse contains the response from method BgpPeersClient.Get. +type BgpPeersClientGetResponse struct { + // A BgpPeer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + BgpPeer +} + +// BgpPeersClientListResponse contains the response from method BgpPeersClient.NewListPager. +type BgpPeersClientListResponse struct { + // The response of a BgpPeer list operation. + BgpPeerListResult +} + +// LoadBalancersClientCreateOrUpdateResponse contains the response from method LoadBalancersClient.BeginCreateOrUpdate. +type LoadBalancersClientCreateOrUpdateResponse struct { + // A LoadBalancer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + LoadBalancer +} + +// LoadBalancersClientDeleteResponse contains the response from method LoadBalancersClient.Delete. +type LoadBalancersClientDeleteResponse struct { + // placeholder for future response values +} + +// LoadBalancersClientGetResponse contains the response from method LoadBalancersClient.Get. +type LoadBalancersClientGetResponse struct { + // A LoadBalancer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + LoadBalancer +} + +// LoadBalancersClientListResponse contains the response from method LoadBalancersClient.NewListPager. +type LoadBalancersClientListResponse struct { + // The response of a LoadBalancer list operation. + LoadBalancerListResult +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// ServicesClientCreateOrUpdateResponse contains the response from method ServicesClient.CreateOrUpdate. +type ServicesClientCreateOrUpdateResponse struct { + // A Service resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + ServiceResource +} + +// ServicesClientDeleteResponse contains the response from method ServicesClient.Delete. +type ServicesClientDeleteResponse struct { + // placeholder for future response values +} + +// ServicesClientGetResponse contains the response from method ServicesClient.Get. +type ServicesClientGetResponse struct { + // A Service resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + ServiceResource +} + +// ServicesClientListResponse contains the response from method ServicesClient.NewListPager. +type ServicesClientListResponse struct { + // The response of a ServiceResource list operation. + ServiceResourceListResult +} + +// StorageClassClientCreateOrUpdateResponse contains the response from method StorageClassClient.BeginCreateOrUpdate. +type StorageClassClientCreateOrUpdateResponse struct { + // A StorageClass resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + StorageClassResource +} + +// StorageClassClientDeleteResponse contains the response from method StorageClassClient.BeginDelete. +type StorageClassClientDeleteResponse struct { + // placeholder for future response values +} + +// StorageClassClientGetResponse contains the response from method StorageClassClient.Get. +type StorageClassClientGetResponse struct { + // A StorageClass resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + StorageClassResource +} + +// StorageClassClientListResponse contains the response from method StorageClassClient.NewListPager. +type StorageClassClientListResponse struct { + // The response of a StorageClassResource list operation. + StorageClassResourceListResult +} + +// StorageClassClientUpdateResponse contains the response from method StorageClassClient.BeginUpdate. +type StorageClassClientUpdateResponse struct { + // A StorageClass resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + StorageClassResource +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/services_client.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/services_client.go new file mode 100644 index 000000000000..7b9c503816e9 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/services_client.go @@ -0,0 +1,258 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +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" +) + +// ServicesClient contains the methods for the Services group. +// Don't use this type directly, use NewServicesClient() instead. +type ServicesClient struct { + internal *arm.Client +} + +// NewServicesClient creates a new instance of ServicesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewServicesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ServicesClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a ServiceResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - serviceName - The name of the the service +// - resource - Resource create parameters. +// - options - ServicesClientCreateOrUpdateOptions contains the optional parameters for the ServicesClient.CreateOrUpdate method. +func (client *ServicesClient) CreateOrUpdate(ctx context.Context, resourceURI string, serviceName string, resource ServiceResource, options *ServicesClientCreateOrUpdateOptions) (ServicesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ServicesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, serviceName, resource, options) + if err != nil { + return ServicesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ServicesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ServicesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, serviceName string, resource ServiceResource, options *ServicesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ServicesClient) createOrUpdateHandleResponse(resp *http.Response) (ServicesClientCreateOrUpdateResponse, error) { + result := ServicesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ServiceResource); err != nil { + return ServicesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a ServiceResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - serviceName - The name of the the service +// - options - ServicesClientDeleteOptions contains the optional parameters for the ServicesClient.Delete method. +func (client *ServicesClient) Delete(ctx context.Context, resourceURI string, serviceName string, options *ServicesClientDeleteOptions) (ServicesClientDeleteResponse, error) { + var err error + const operationName = "ServicesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceURI, serviceName, options) + if err != nil { + return ServicesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ServicesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ServicesClientDeleteResponse{}, err + } + return ServicesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceURI string, serviceName string, options *ServicesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a ServiceResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - serviceName - The name of the the service +// - options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. +func (client *ServicesClient) Get(ctx context.Context, resourceURI string, serviceName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { + var err error + const operationName = "ServicesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, serviceName, options) + if err != nil { + return ServicesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ServicesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ServicesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ServicesClient) getCreateRequest(ctx context.Context, resourceURI string, serviceName string, options *ServicesClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesClientGetResponse, error) { + result := ServicesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ServiceResource); err != nil { + return ServicesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List ServiceResource resources by parent +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. +func (client *ServicesClient) NewListPager(resourceURI string, options *ServicesClientListOptions) *runtime.Pager[ServicesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ServicesClientListResponse]{ + More: func(page ServicesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ServicesClientListResponse) (ServicesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ServicesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return ServicesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ServicesClient) listCreateRequest(ctx context.Context, resourceURI string, options *ServicesClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/services" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ServicesClient) listHandleResponse(resp *http.Response) (ServicesClientListResponse, error) { + result := ServicesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ServiceResourceListResult); err != nil { + return ServicesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/storageclass_client.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/storageclass_client.go new file mode 100644 index 000000000000..4e8996e8fbe5 --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/storageclass_client.go @@ -0,0 +1,368 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +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" +) + +// StorageClassClient contains the methods for the StorageClass group. +// Don't use this type directly, use NewStorageClassClient() instead. +type StorageClassClient struct { + internal *arm.Client +} + +// NewStorageClassClient creates a new instance of StorageClassClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewStorageClassClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*StorageClassClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &StorageClassClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - storageClassName - The name of the the storage class +// - resource - Resource create parameters. +// - options - StorageClassClientBeginCreateOrUpdateOptions contains the optional parameters for the StorageClassClient.BeginCreateOrUpdate +// method. +func (client *StorageClassClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, storageClassName string, resource StorageClassResource, options *StorageClassClientBeginCreateOrUpdateOptions) (*runtime.Poller[StorageClassClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, storageClassName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageClassClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StorageClassClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *StorageClassClient) createOrUpdate(ctx context.Context, resourceURI string, storageClassName string, resource StorageClassResource, options *StorageClassClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "StorageClassClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, storageClassName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StorageClassClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, storageClassName string, resource StorageClassResource, options *StorageClassClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if storageClassName == "" { + return nil, errors.New("parameter storageClassName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageClassName}", url.PathEscape(storageClassName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - storageClassName - The name of the the storage class +// - options - StorageClassClientBeginDeleteOptions contains the optional parameters for the StorageClassClient.BeginDelete +// method. +func (client *StorageClassClient) BeginDelete(ctx context.Context, resourceURI string, storageClassName string, options *StorageClassClientBeginDeleteOptions) (*runtime.Poller[StorageClassClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceURI, storageClassName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageClassClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StorageClassClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *StorageClassClient) deleteOperation(ctx context.Context, resourceURI string, storageClassName string, options *StorageClassClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "StorageClassClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceURI, storageClassName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StorageClassClient) deleteCreateRequest(ctx context.Context, resourceURI string, storageClassName string, options *StorageClassClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if storageClassName == "" { + return nil, errors.New("parameter storageClassName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageClassName}", url.PathEscape(storageClassName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - storageClassName - The name of the the storage class +// - options - StorageClassClientGetOptions contains the optional parameters for the StorageClassClient.Get method. +func (client *StorageClassClient) Get(ctx context.Context, resourceURI string, storageClassName string, options *StorageClassClientGetOptions) (StorageClassClientGetResponse, error) { + var err error + const operationName = "StorageClassClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, storageClassName, options) + if err != nil { + return StorageClassClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StorageClassClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StorageClassClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *StorageClassClient) getCreateRequest(ctx context.Context, resourceURI string, storageClassName string, options *StorageClassClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if storageClassName == "" { + return nil, errors.New("parameter storageClassName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageClassName}", url.PathEscape(storageClassName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *StorageClassClient) getHandleResponse(resp *http.Response) (StorageClassClientGetResponse, error) { + result := StorageClassClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageClassResource); err != nil { + return StorageClassClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List StorageClassResource resources by parent +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - StorageClassClientListOptions contains the optional parameters for the StorageClassClient.NewListPager method. +func (client *StorageClassClient) NewListPager(resourceURI string, options *StorageClassClientListOptions) *runtime.Pager[StorageClassClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[StorageClassClientListResponse]{ + More: func(page StorageClassClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StorageClassClientListResponse) (StorageClassClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "StorageClassClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return StorageClassClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *StorageClassClient) listCreateRequest(ctx context.Context, resourceURI string, options *StorageClassClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *StorageClassClient) listHandleResponse(resp *http.Response) (StorageClassClientListResponse, error) { + result := StorageClassClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageClassResourceListResult); err != nil { + return StorageClassClientListResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - storageClassName - The name of the the storage class +// - properties - The resource properties to be updated. +// - options - StorageClassClientBeginUpdateOptions contains the optional parameters for the StorageClassClient.BeginUpdate +// method. +func (client *StorageClassClient) BeginUpdate(ctx context.Context, resourceURI string, storageClassName string, properties StorageClassResourceUpdate, options *StorageClassClientBeginUpdateOptions) (*runtime.Poller[StorageClassClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceURI, storageClassName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageClassClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StorageClassClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a StorageClassResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *StorageClassClient) update(ctx context.Context, resourceURI string, storageClassName string, properties StorageClassResourceUpdate, options *StorageClassClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "StorageClassClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceURI, storageClassName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *StorageClassClient) updateCreateRequest(ctx context.Context, resourceURI string, storageClassName string, properties StorageClassResourceUpdate, options *StorageClassClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if storageClassName == "" { + return nil, errors.New("parameter storageClassName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageClassName}", url.PathEscape(storageClassName)) + 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", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/time_rfc3339.go b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/time_rfc3339.go new file mode 100644 index 000000000000..9eee6e764a3a --- /dev/null +++ b/sdk/resourcemanager/kubernetesruntime/armkubernetesruntime/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armkubernetesruntime + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}