diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/CHANGELOG.md b/sdk/resourcemanager/kubernetesconfiguration/armextensions/CHANGELOG.md new file mode 100644 index 000000000000..20d64faf0eee --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-13) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions` 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/kubernetesconfiguration/armextensions/LICENSE.txt b/sdk/resourcemanager/kubernetesconfiguration/armextensions/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/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/kubernetesconfiguration/armextensions/README.md b/sdk/resourcemanager/kubernetesconfiguration/armextensions/README.md new file mode 100644 index 000000000000..f335540d6bf4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/README.md @@ -0,0 +1,90 @@ +# Azure Kubernetesconfiguration Module for Go + +The `armextensions` module provides operations for working with Azure Kubernetesconfiguration. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kubernetesconfiguration/armextensions) + +# 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 Kubernetesconfiguration module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetesconfiguration. 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 Kubernetesconfiguration 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 := armextensions.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 := armextensions.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.NewClient() +``` + +## 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 `Kubernetesconfiguration` 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/kubernetesconfiguration/armextensions/autorest.md b/sdk/resourcemanager/kubernetesconfiguration/armextensions/autorest.md new file mode 100644 index 000000000000..3c0d58386a88 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/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/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensions/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/build.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/build.go new file mode 100644 index 000000000000..7996b766f09e --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/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/kubernetesconfiguration/armextensions + +package armextensions diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/ci.yml b/sdk/resourcemanager/kubernetesconfiguration/armextensions/ci.yml new file mode 100644 index 000000000000..196e42d58aa5 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/ci.yml @@ -0,0 +1,27 @@ +# 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/kubernetesconfiguration/armextensions/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kubernetesconfiguration/armextensions/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/kubernetesconfiguration/armextensions' diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/client.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/client.go new file mode 100644 index 000000000000..3186dd333e5d --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/client.go @@ -0,0 +1,484 @@ +// 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 armextensions + +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" + "strconv" + "strings" +) + +// Client contains the methods for the Extensions group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a new Kubernetes Cluster Extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionName - Name of the Extension. +// - extension - Properties necessary to Create an Extension. +// - options - ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +func (client *Client) BeginCreate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension Extension, options *ClientBeginCreateOptions) (*runtime.Poller[ClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, extension, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a new Kubernetes Cluster Extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +func (client *Client) create(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension Extension, options *ClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, extension, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *Client) createCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension Extension, _ *ClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + 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-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, extension); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension from the cluster. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionName - Name of the Extension. +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension from the cluster. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + 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-11-01") + if options != nil && options.ForceDelete != nil { + reqQP.Set("forceDelete", strconv.FormatBool(*options.ForceDelete)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets Kubernetes Cluster Extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionName - Name of the Extension. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + 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-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Extension); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all Extensions in the cluster. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. +func (client *Client) NewListPager(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ + More: func(page ClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListResponse) (ClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) + if err != nil { + return ClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, _ *ClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *Client) listHandleResponse(resp *http.Response) (ClientListResponse, error) { + result := ClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return ClientListResponse{}, err + } + return result, nil +} + +// BeginUpdate - Patch an existing Kubernetes Cluster Extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionName - Name of the Extension. +// - patchExtension - Properties to Patch in an existing Extension. +// - options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension PatchExtension, options *ClientBeginUpdateOptions) (*runtime.Poller[ClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, patchExtension, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Patch an existing Kubernetes Cluster Extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +func (client *Client) update(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension PatchExtension, options *ClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, patchExtension, 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 *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension PatchExtension, _ *ClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + 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-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, patchExtension); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/client_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/client_factory.go new file mode 100644 index 000000000000..3d714c34c8e2 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/client_factory.go @@ -0,0 +1,50 @@ +// 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 armextensions + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationStatusClient creates a new instance of OperationStatusClient. +func (c *ClientFactory) NewOperationStatusClient() *OperationStatusClient { + return &OperationStatusClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/constants.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/constants.go new file mode 100644 index 000000000000..8e25ba8d954e --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/constants.go @@ -0,0 +1,89 @@ +// 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 armextensions + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions" + moduleVersion = "v0.1.0" +) + +// AKSIdentityType - The identity type. +type AKSIdentityType string + +const ( + AKSIdentityTypeSystemAssigned AKSIdentityType = "SystemAssigned" + AKSIdentityTypeUserAssigned AKSIdentityType = "UserAssigned" +) + +// PossibleAKSIdentityTypeValues returns the possible values for the AKSIdentityType const type. +func PossibleAKSIdentityTypeValues() []AKSIdentityType { + return []AKSIdentityType{ + AKSIdentityTypeSystemAssigned, + AKSIdentityTypeUserAssigned, + } +} + +// 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, + } +} + +// LevelType - Level of the status. +type LevelType string + +const ( + LevelTypeError LevelType = "Error" + LevelTypeInformation LevelType = "Information" + LevelTypeWarning LevelType = "Warning" +) + +// PossibleLevelTypeValues returns the possible values for the LevelType const type. +func PossibleLevelTypeValues() []LevelType { + return []LevelType{ + LevelTypeError, + LevelTypeInformation, + LevelTypeWarning, + } +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/internal.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/internal.go new file mode 100644 index 000000000000..0e32a8018fe4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/internal.go @@ -0,0 +1,77 @@ +// 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 result struct { + resp *http.Response + err error +} + +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 parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +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/kubernetesconfiguration/armextensions/fake/operationstatus_server.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/operationstatus_server.go new file mode 100644 index 000000000000..097dfd4de3ed --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/operationstatus_server.go @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusServer is a fake server for instances of the armextensions.OperationStatusClient type. +type OperationStatusServer struct { + // Get is the fake for method OperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, operationID string, options *armextensions.OperationStatusClientGetOptions) (resp azfake.Responder[armextensions.OperationStatusClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationStatusServerTransport creates a new instance of OperationStatusServerTransport with the provided implementation. +// The returned OperationStatusServerTransport instance is connected to an instance of armextensions.OperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusServerTransport(srv *OperationStatusServer) *OperationStatusServerTransport { + return &OperationStatusServerTransport{srv: srv} +} + +// OperationStatusServerTransport connects instances of armextensions.OperationStatusClient to instances of OperationStatusServer. +// Don't use this type directly, use NewOperationStatusServerTransport instead. +type OperationStatusServerTransport struct { + srv *OperationStatusServer +} + +// Do implements the policy.Transporter interface for OperationStatusServerTransport. +func (o *OperationStatusServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationStatusServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationStatusServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationStatusClient.Get": + res.resp, res.err = o.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, operationIDParam, 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).OperationStatusResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationStatusServerTransport +var operationStatusServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server.go new file mode 100644 index 000000000000..b19344169055 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server.go @@ -0,0 +1,410 @@ +// 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/kubernetesconfiguration/armextensions" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// Server is a fake server for instances of the armextensions.Client type. +type Server struct { + // BeginCreate is the fake for method Client.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension armextensions.Extension, options *armextensions.ClientBeginCreateOptions) (resp azfake.PollerResponder[armextensions.ClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method Client.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *armextensions.ClientBeginDeleteOptions) (resp azfake.PollerResponder[armextensions.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *armextensions.ClientGetOptions) (resp azfake.Responder[armextensions.ClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method Client.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armextensions.ClientListOptions) (resp azfake.PagerResponder[armextensions.ClientListResponse]) + + // BeginUpdate is the fake for method Client.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension armextensions.PatchExtension, options *armextensions.ClientBeginUpdateOptions) (resp azfake.PollerResponder[armextensions.ClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armextensions.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armextensions.ClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armextensions.ClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armextensions.ClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armextensions.ClientUpdateResponse]](), + } +} + +// ServerTransport connects instances of armextensions.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginCreate *tracker[azfake.PollerResponder[armextensions.ClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armextensions.ClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armextensions.ClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armextensions.ClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginCreate": + res.resp, res.err = s.dispatchBeginCreate(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := s.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armextensions.Extension](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + s.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + s.beginCreate.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + forceDeleteUnescaped, err := url.QueryUnescape(qp.Get("forceDelete")) + if err != nil { + return nil, err + } + forceDeleteParam, err := parseOptional(forceDeleteUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armextensions.ClientBeginDeleteOptions + if forceDeleteParam != nil { + options = &armextensions.ClientBeginDeleteOptions{ + ForceDelete: forceDeleteParam, + } + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, options) + 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.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, 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).Extension, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armextensions.ClientListResponse, 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 *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armextensions.PatchExtension](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, 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 +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server_factory.go new file mode 100644 index 000000000000..0bf3c4d0b065 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/fake/server_factory.go @@ -0,0 +1,82 @@ +// 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 armextensions.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // OperationStatusServer contains the fakes for client OperationStatusClient + OperationStatusServer OperationStatusServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armextensions.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 armextensions.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trOperationStatusServer *OperationStatusServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "OperationStatusClient": + initServer(s, &s.trOperationStatusServer, func() *OperationStatusServerTransport { + return NewOperationStatusServerTransport(&s.srv.OperationStatusServer) + }) + resp, err = s.trOperationStatusServer.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/kubernetesconfiguration/armextensions/go.mod b/sdk/resourcemanager/kubernetesconfiguration/armextensions/go.mod new file mode 100644 index 000000000000..499982bbeda1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/go.sum b/sdk/resourcemanager/kubernetesconfiguration/armextensions/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/models.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/models.go new file mode 100644 index 000000000000..80c7743aae76 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/models.go @@ -0,0 +1,269 @@ +// 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 armextensions + +import "time" + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// Extension - The Extension object. +type Extension struct { + // Identity of the Extension resource + Identity *Identity + + // The plan information. + Plan *Plan + + // Properties of an Extension resource + Properties *ExtensionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ExtensionProperties - Properties of an Extension resource +type ExtensionProperties struct { + // Identity of the Extension resource in an AKS cluster + AksAssignedIdentity *ExtensionPropertiesAksAssignedIdentity + + // Flag to note if this extension participates in auto upgrade of minor version, or not. + AutoUpgradeMinorVersion *bool + + // Configuration settings that are sensitive, as name-value pairs for configuring this extension. + ConfigurationProtectedSettings map[string]*string + + // Configuration settings, as name-value pairs for configuring this extension. + ConfigurationSettings map[string]*string + + // Type of the Extension, of which this resource is an instance of. It must be one of the Extension Types registered with + // Microsoft.KubernetesConfiguration by the Extension publisher. + ExtensionType *string + + // ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, Preview, etc.) - only if autoUpgradeMinorVersion + // is 'true'. + ReleaseTrain *string + + // Scope at which the extension is installed. + Scope *Scope + + // Status from this extension. + Statuses []*ExtensionStatus + + // User-specified version of the extension for this extension to 'pin'. To use 'version', autoUpgradeMinorVersion must be + // 'false'. + Version *string + + // READ-ONLY; Currently installed version of the extension. + CurrentVersion *string + + // READ-ONLY; Custom Location settings properties. + CustomLocationSettings map[string]*string + + // READ-ONLY; Error information from the Agent - e.g. errors during installation. + ErrorInfo *ErrorDetail + + // READ-ONLY; Flag to note if this extension is a system extension + IsSystemExtension *bool + + // READ-ONLY; Uri of the Helm package + PackageURI *string + + // READ-ONLY; Status of installation of this extension. + ProvisioningState *ProvisioningState +} + +// ExtensionPropertiesAksAssignedIdentity - Identity of the Extension resource in an AKS cluster +type ExtensionPropertiesAksAssignedIdentity struct { + // The identity type. + Type *AKSIdentityType + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of resource. + TenantID *string +} + +// ExtensionStatus - Status from the extension. +type ExtensionStatus struct { + // Status code provided by the Extension + Code *string + + // Short description of status of the extension. + DisplayStatus *string + + // Level of the status. + Level *LevelType + + // Detailed message of the status from the Extension. + Message *string + + // DateLiteral (per ISO8601) noting the time of installation status. + Time *string +} + +// Identity for the resource. +type Identity struct { + // CONSTANT; The identity type. + // Field has constant value "SystemAssigned", any specified value is ignored. + Type *string + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of resource. + TenantID *string +} + +// List - Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next +// set of results. +type List struct { + // READ-ONLY; URL to get the next set of extension objects, if any. + NextLink *string + + // READ-ONLY; List of Extensions within a Kubernetes cluster. + Value []*Extension +} + +// OperationStatusResult - The current status of an async operation. +type OperationStatusResult struct { + // REQUIRED; Operation status. + Status *string + + // Fully qualified ID for the async operation. + ID *string + + // Name of the async operation. + Name *string + + // Additional information, if available. + Properties map[string]*string + + // READ-ONLY; If present, details of the operation error. + Error *ErrorDetail +} + +// PatchExtension - The Extension Patch Request object. +type PatchExtension struct { + // Updatable properties of an Extension Patch Request + Properties *PatchExtensionProperties +} + +// PatchExtensionProperties - Updatable properties of an Extension Patch Request +type PatchExtensionProperties struct { + // Flag to note if this extension participates in auto upgrade of minor version, or not. + AutoUpgradeMinorVersion *bool + + // Configuration settings that are sensitive, as name-value pairs for configuring this extension. + ConfigurationProtectedSettings map[string]*string + + // Configuration settings, as name-value pairs for configuring this extension. + ConfigurationSettings map[string]*string + + // ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, Preview, etc.) - only if autoUpgradeMinorVersion + // is 'true'. + ReleaseTrain *string + + // Version of the extension for this extension, if it is 'pinned' to a specific version. autoUpgradeMinorVersion must be 'false'. + Version *string +} + +// Plan for the resource. +type Plan struct { + // REQUIRED; A user defined name of the 3rd Party Artifact that is being procured. + Name *string + + // REQUIRED; The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact + // at the time of Data Market onboarding. + Product *string + + // REQUIRED; The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string + + // A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string + + // The version of the desired product/artifact. + Version *string +} + +// Scope of the extension. It can be either Cluster or Namespace; but not both. +type Scope struct { + // Specifies that the scope of the extension is Cluster + Cluster *ScopeCluster + + // Specifies that the scope of the extension is Namespace + Namespace *ScopeNamespace +} + +// ScopeCluster - Specifies that the scope of the extension is Cluster +type ScopeCluster struct { + // Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, + // it will be created + ReleaseNamespace *string +} + +// ScopeNamespace - Specifies that the scope of the extension is Namespace +type ScopeNamespace struct { + // Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will + // be created + TargetNamespace *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/kubernetesconfiguration/armextensions/models_serde.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/models_serde.go new file mode 100644 index 000000000000..6d9b0b29f2cf --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/models_serde.go @@ -0,0 +1,683 @@ +// 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 armextensions + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Extension. +func (e Extension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "name", e.Name) + populate(objectMap, "plan", e.Plan) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Extension. +func (e *Extension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &e.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionProperties. +func (e ExtensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aksAssignedIdentity", e.AksAssignedIdentity) + populate(objectMap, "autoUpgradeMinorVersion", e.AutoUpgradeMinorVersion) + populate(objectMap, "configurationProtectedSettings", e.ConfigurationProtectedSettings) + populate(objectMap, "configurationSettings", e.ConfigurationSettings) + populate(objectMap, "currentVersion", e.CurrentVersion) + populate(objectMap, "customLocationSettings", e.CustomLocationSettings) + populate(objectMap, "errorInfo", e.ErrorInfo) + populate(objectMap, "extensionType", e.ExtensionType) + populate(objectMap, "isSystemExtension", e.IsSystemExtension) + populate(objectMap, "packageUri", e.PackageURI) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "releaseTrain", e.ReleaseTrain) + populate(objectMap, "scope", e.Scope) + populate(objectMap, "statuses", e.Statuses) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionProperties. +func (e *ExtensionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aksAssignedIdentity": + err = unpopulate(val, "AksAssignedIdentity", &e.AksAssignedIdentity) + delete(rawMsg, key) + case "autoUpgradeMinorVersion": + err = unpopulate(val, "AutoUpgradeMinorVersion", &e.AutoUpgradeMinorVersion) + delete(rawMsg, key) + case "configurationProtectedSettings": + err = unpopulate(val, "ConfigurationProtectedSettings", &e.ConfigurationProtectedSettings) + delete(rawMsg, key) + case "configurationSettings": + err = unpopulate(val, "ConfigurationSettings", &e.ConfigurationSettings) + delete(rawMsg, key) + case "currentVersion": + err = unpopulate(val, "CurrentVersion", &e.CurrentVersion) + delete(rawMsg, key) + case "customLocationSettings": + err = unpopulate(val, "CustomLocationSettings", &e.CustomLocationSettings) + delete(rawMsg, key) + case "errorInfo": + err = unpopulate(val, "ErrorInfo", &e.ErrorInfo) + delete(rawMsg, key) + case "extensionType": + err = unpopulate(val, "ExtensionType", &e.ExtensionType) + delete(rawMsg, key) + case "isSystemExtension": + err = unpopulate(val, "IsSystemExtension", &e.IsSystemExtension) + delete(rawMsg, key) + case "packageUri": + err = unpopulate(val, "PackageURI", &e.PackageURI) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "releaseTrain": + err = unpopulate(val, "ReleaseTrain", &e.ReleaseTrain) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &e.Scope) + delete(rawMsg, key) + case "statuses": + err = unpopulate(val, "Statuses", &e.Statuses) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &e.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionPropertiesAksAssignedIdentity. +func (e ExtensionPropertiesAksAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", e.PrincipalID) + populate(objectMap, "tenantId", e.TenantID) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionPropertiesAksAssignedIdentity. +func (e *ExtensionPropertiesAksAssignedIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &e.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &e.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionStatus. +func (e ExtensionStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "displayStatus", e.DisplayStatus) + populate(objectMap, "level", e.Level) + populate(objectMap, "message", e.Message) + populate(objectMap, "time", e.Time) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionStatus. +func (e *ExtensionStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "displayStatus": + err = unpopulate(val, "DisplayStatus", &e.DisplayStatus) + delete(rawMsg, key) + case "level": + err = unpopulate(val, "Level", &e.Level) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &e.Time) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + objectMap["type"] = "SystemAssigned" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type List. +func (l List) 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 List. +func (l *List) UnmarshalJSON(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 OperationStatusResult. +func (o OperationStatusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusResult. +func (o *OperationStatusResult) UnmarshalJSON(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 "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + 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 PatchExtension. +func (p PatchExtension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PatchExtension. +func (p *PatchExtension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PatchExtensionProperties. +func (p PatchExtensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoUpgradeMinorVersion", p.AutoUpgradeMinorVersion) + populate(objectMap, "configurationProtectedSettings", p.ConfigurationProtectedSettings) + populate(objectMap, "configurationSettings", p.ConfigurationSettings) + populate(objectMap, "releaseTrain", p.ReleaseTrain) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PatchExtensionProperties. +func (p *PatchExtensionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoUpgradeMinorVersion": + err = unpopulate(val, "AutoUpgradeMinorVersion", &p.AutoUpgradeMinorVersion) + delete(rawMsg, key) + case "configurationProtectedSettings": + err = unpopulate(val, "ConfigurationProtectedSettings", &p.ConfigurationProtectedSettings) + delete(rawMsg, key) + case "configurationSettings": + err = unpopulate(val, "ConfigurationSettings", &p.ConfigurationSettings) + delete(rawMsg, key) + case "releaseTrain": + err = unpopulate(val, "ReleaseTrain", &p.ReleaseTrain) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Plan. +func (p Plan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "product", p.Product) + populate(objectMap, "promotionCode", p.PromotionCode) + populate(objectMap, "publisher", p.Publisher) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Plan. +func (p *Plan) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &p.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &p.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &p.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Scope. +func (s Scope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cluster", s.Cluster) + populate(objectMap, "namespace", s.Namespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Scope. +func (s *Scope) UnmarshalJSON(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 "cluster": + err = unpopulate(val, "Cluster", &s.Cluster) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &s.Namespace) + 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 ScopeCluster. +func (s ScopeCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "releaseNamespace", s.ReleaseNamespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopeCluster. +func (s *ScopeCluster) UnmarshalJSON(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 "releaseNamespace": + err = unpopulate(val, "ReleaseNamespace", &s.ReleaseNamespace) + 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 ScopeNamespace. +func (s ScopeNamespace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetNamespace", s.TargetNamespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopeNamespace. +func (s *ScopeNamespace) UnmarshalJSON(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 "targetNamespace": + err = unpopulate(val, "TargetNamespace", &s.TargetNamespace) + 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 populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/operationstatus_client.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/operationstatus_client.go new file mode 100644 index 000000000000..a63359d96542 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/operationstatus_client.go @@ -0,0 +1,126 @@ +// 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 armextensions + +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" +) + +// OperationStatusClient contains the methods for the OperationStatus group. +// Don't use this type directly, use NewOperationStatusClient() instead. +type OperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOperationStatusClient creates a new instance of OperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get Async Operation status +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionName - Name of the Extension. +// - operationID - operation Id +// - options - OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. +func (client *OperationStatusClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, operationID string, options *OperationStatusClientGetOptions) (OperationStatusClientGetResponse, error) { + var err error + const operationName = "OperationStatusClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, operationID, options) + if err != nil { + return OperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, operationID string, _ *OperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationStatusClient) getHandleResponse(resp *http.Response) (OperationStatusClientGetResponse, error) { + result := OperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatusResult); err != nil { + return OperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/options.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/options.go new file mode 100644 index 000000000000..705a6a8a5056 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/options.go @@ -0,0 +1,42 @@ +// 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 armextensions + +// ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +type ClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +type ClientBeginDeleteOptions struct { + // Delete the extension resource in Azure - not the normal asynchronous delete. + ForceDelete *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +type ClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListOptions contains the optional parameters for the Client.NewListPager method. +type ClientListOptions struct { + // placeholder for future optional parameters +} + +// OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. +type OperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/responses.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/responses.go new file mode 100644 index 000000000000..644e1556e90b --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/responses.go @@ -0,0 +1,42 @@ +// 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 armextensions + +// ClientCreateResponse contains the response from method Client.BeginCreate. +type ClientCreateResponse struct { + // The Extension object. + Extension +} + +// ClientDeleteResponse contains the response from method Client.BeginDelete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // The Extension object. + Extension +} + +// ClientListResponse contains the response from method Client.NewListPager. +type ClientListResponse struct { + // Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of + // results. + List +} + +// ClientUpdateResponse contains the response from method Client.BeginUpdate. +type ClientUpdateResponse struct { + // The Extension object. + Extension +} + +// OperationStatusClientGetResponse contains the response from method OperationStatusClient.Get. +type OperationStatusClientGetResponse struct { + // The current status of an async operation. + OperationStatusResult +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensions/time_rfc3339.go b/sdk/resourcemanager/kubernetesconfiguration/armextensions/time_rfc3339.go new file mode 100644 index 000000000000..d998648ccd91 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensions/time_rfc3339.go @@ -0,0 +1,110 @@ +// 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 armextensions + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/CHANGELOG.md b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/CHANGELOG.md new file mode 100644 index 000000000000..86aae275e7bc --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-13) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes` 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/kubernetesconfiguration/armextensiontypes/LICENSE.txt b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/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/kubernetesconfiguration/armextensiontypes/README.md b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/README.md new file mode 100644 index 000000000000..15ca392a1ea4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/README.md @@ -0,0 +1,90 @@ +# Azure Kubernetesconfiguration Module for Go + +The `armextensiontypes` module provides operations for working with Azure Kubernetesconfiguration. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes) + +# 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 Kubernetesconfiguration module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetesconfiguration. 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 Kubernetesconfiguration 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 := armextensiontypes.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 := armextensiontypes.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.NewClient() +``` + +## 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 `Kubernetesconfiguration` 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/kubernetesconfiguration/armextensiontypes/autorest.md b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/autorest.md new file mode 100644 index 000000000000..1d4dcfdf8281 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/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/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensionTypes/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensionTypes/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/build.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/build.go new file mode 100644 index 000000000000..12a6bf0c5e23 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/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/kubernetesconfiguration/armextensiontypes + +package armextensiontypes diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/ci.yml b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/ci.yml new file mode 100644 index 000000000000..9b4eb8ca6e1b --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/ci.yml @@ -0,0 +1,27 @@ +# 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/kubernetesconfiguration/armextensiontypes/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/kubernetesconfiguration/armextensiontypes' diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client.go new file mode 100644 index 000000000000..f020306f7cc4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client.go @@ -0,0 +1,667 @@ +// 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 armextensiontypes + +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" + "strconv" + "strings" +) + +// Client contains the methods for the ExtensionTypes group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// ClusterGetVersion - Get details of a version for an Extension Type installable to the cluster. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionTypeName - Name of the Extension Type. +// - versionNumber - Version number of the Extension Type. +// - options - ClientClusterGetVersionOptions contains the optional parameters for the Client.ClusterGetVersion method. +func (client *Client) ClusterGetVersion(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, versionNumber string, options *ClientClusterGetVersionOptions) (ClientClusterGetVersionResponse, error) { + var err error + const operationName = "Client.ClusterGetVersion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.clusterGetVersionCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionTypeName, versionNumber, options) + if err != nil { + return ClientClusterGetVersionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientClusterGetVersionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientClusterGetVersionResponse{}, err + } + resp, err := client.clusterGetVersionHandleResponse(httpResp) + return resp, err +} + +// clusterGetVersionCreateRequest creates the ClusterGetVersion request. +func (client *Client) clusterGetVersionCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, versionNumber string, _ *ClientClusterGetVersionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}/versions/{versionNumber}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + if versionNumber == "" { + return nil, errors.New("parameter versionNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionNumber}", url.PathEscape(versionNumber)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// clusterGetVersionHandleResponse handles the ClusterGetVersion response. +func (client *Client) clusterGetVersionHandleResponse(resp *http.Response) (ClientClusterGetVersionResponse, error) { + result := ClientClusterGetVersionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionTypeVersionForReleaseTrain); err != nil { + return ClientClusterGetVersionResponse{}, err + } + return result, nil +} + +// NewClusterListVersionsPager - List the version for an Extension Type installable to the cluster. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionTypeName - Name of the Extension Type. +// - options - ClientClusterListVersionsOptions contains the optional parameters for the Client.NewClusterListVersionsPager +// method. +func (client *Client) NewClusterListVersionsPager(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, options *ClientClusterListVersionsOptions) *runtime.Pager[ClientClusterListVersionsResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientClusterListVersionsResponse]{ + More: func(page ClientClusterListVersionsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientClusterListVersionsResponse) (ClientClusterListVersionsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewClusterListVersionsPager") + 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.clusterListVersionsCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionTypeName, options) + }, nil) + if err != nil { + return ClientClusterListVersionsResponse{}, err + } + return client.clusterListVersionsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// clusterListVersionsCreateRequest creates the ClusterListVersions request. +func (client *Client) clusterListVersionsCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, options *ClientClusterListVersionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}/versions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + 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-11-01-preview") + if options != nil && options.MajorVersion != nil { + reqQP.Set("majorVersion", *options.MajorVersion) + } + if options != nil && options.ReleaseTrain != nil { + reqQP.Set("releaseTrain", *options.ReleaseTrain) + } + if options != nil && options.ShowLatest != nil { + reqQP.Set("showLatest", strconv.FormatBool(*options.ShowLatest)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// clusterListVersionsHandleResponse handles the ClusterListVersions response. +func (client *Client) clusterListVersionsHandleResponse(resp *http.Response) (ClientClusterListVersionsResponse, error) { + result := ClientClusterListVersionsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionTypeVersionsList); err != nil { + return ClientClusterListVersionsResponse{}, err + } + return result, nil +} + +// Get - Get an Extension Type installable to the cluster based region and type for the cluster. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - extensionTypeName - Name of the Extension Type. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionTypeName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionType); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// GetVersion - Get details of a version for an extension type and location +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - location - The name of Azure region. +// - extensionTypeName - Name of the Extension Type. +// - versionNumber - Version number of the Extension Type. +// - options - ClientGetVersionOptions contains the optional parameters for the Client.GetVersion method. +func (client *Client) GetVersion(ctx context.Context, location string, extensionTypeName string, versionNumber string, options *ClientGetVersionOptions) (ClientGetVersionResponse, error) { + var err error + const operationName = "Client.GetVersion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getVersionCreateRequest(ctx, location, extensionTypeName, versionNumber, options) + if err != nil { + return ClientGetVersionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetVersionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetVersionResponse{}, err + } + resp, err := client.getVersionHandleResponse(httpResp) + return resp, err +} + +// getVersionCreateRequest creates the GetVersion request. +func (client *Client) getVersionCreateRequest(ctx context.Context, location string, extensionTypeName string, versionNumber string, _ *ClientGetVersionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions/{versionNumber}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + if versionNumber == "" { + return nil, errors.New("parameter versionNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionNumber}", url.PathEscape(versionNumber)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getVersionHandleResponse handles the GetVersion response. +func (client *Client) getVersionHandleResponse(resp *http.Response) (ClientGetVersionResponse, error) { + result := ClientGetVersionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionTypeVersionForReleaseTrain); err != nil { + return ClientGetVersionResponse{}, err + } + return result, nil +} + +// NewListPager - List installable Extension Types for the cluster based region and type for the cluster. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. +func (client *Client) NewListPager(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ + More: func(page ClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListResponse) (ClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) + if err != nil { + return ClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *ClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-11-01-preview") + if options != nil && options.OfferID != nil { + reqQP.Set("offerId", *options.OfferID) + } + if options != nil && options.PlanID != nil { + reqQP.Set("planId", *options.PlanID) + } + if options != nil && options.PublisherID != nil { + reqQP.Set("publisherId", *options.PublisherID) + } + if options != nil && options.ReleaseTrain != nil { + reqQP.Set("releaseTrain", *options.ReleaseTrain) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *Client) listHandleResponse(resp *http.Response) (ClientListResponse, error) { + result := ClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return ClientListResponse{}, err + } + return result, nil +} + +// NewListVersionsPager - List the versions for an extension type and location. +// +// Generated from API version 2024-11-01-preview +// - location - The name of Azure region. +// - extensionTypeName - Name of the Extension Type. +// - options - ClientListVersionsOptions contains the optional parameters for the Client.NewListVersionsPager method. +func (client *Client) NewListVersionsPager(location string, extensionTypeName string, options *ClientListVersionsOptions) *runtime.Pager[ClientListVersionsResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListVersionsResponse]{ + More: func(page ClientListVersionsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListVersionsResponse) (ClientListVersionsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListVersionsPager") + 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.listVersionsCreateRequest(ctx, location, extensionTypeName, options) + }, nil) + if err != nil { + return ClientListVersionsResponse{}, err + } + return client.listVersionsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listVersionsCreateRequest creates the ListVersions request. +func (client *Client) listVersionsCreateRequest(ctx context.Context, location string, extensionTypeName string, options *ClientListVersionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + 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-11-01-preview") + if options != nil && options.ClusterType != nil { + reqQP.Set("clusterType", *options.ClusterType) + } + if options != nil && options.MajorVersion != nil { + reqQP.Set("majorVersion", *options.MajorVersion) + } + if options != nil && options.ReleaseTrain != nil { + reqQP.Set("releaseTrain", *options.ReleaseTrain) + } + if options != nil && options.ShowLatest != nil { + reqQP.Set("showLatest", strconv.FormatBool(*options.ShowLatest)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listVersionsHandleResponse handles the ListVersions response. +func (client *Client) listVersionsHandleResponse(resp *http.Response) (ClientListVersionsResponse, error) { + result := ClientListVersionsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionTypeVersionsList); err != nil { + return ClientListVersionsResponse{}, err + } + return result, nil +} + +// LocationGet - Get an extension type for the location. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - location - The name of Azure region. +// - extensionTypeName - Name of the Extension Type. +// - options - ClientLocationGetOptions contains the optional parameters for the Client.LocationGet method. +func (client *Client) LocationGet(ctx context.Context, location string, extensionTypeName string, options *ClientLocationGetOptions) (ClientLocationGetResponse, error) { + var err error + const operationName = "Client.LocationGet" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.locationGetCreateRequest(ctx, location, extensionTypeName, options) + if err != nil { + return ClientLocationGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientLocationGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientLocationGetResponse{}, err + } + resp, err := client.locationGetHandleResponse(httpResp) + return resp, err +} + +// locationGetCreateRequest creates the LocationGet request. +func (client *Client) locationGetCreateRequest(ctx context.Context, location string, extensionTypeName string, _ *ClientLocationGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if extensionTypeName == "" { + return nil, errors.New("parameter extensionTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionTypeName}", url.PathEscape(extensionTypeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// locationGetHandleResponse handles the LocationGet response. +func (client *Client) locationGetHandleResponse(resp *http.Response) (ClientLocationGetResponse, error) { + result := ClientLocationGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionType); err != nil { + return ClientLocationGetResponse{}, err + } + return result, nil +} + +// NewLocationListPager - List all Extension Types for the location. +// +// Generated from API version 2024-11-01-preview +// - location - The name of Azure region. +// - options - ClientLocationListOptions contains the optional parameters for the Client.NewLocationListPager method. +func (client *Client) NewLocationListPager(location string, options *ClientLocationListOptions) *runtime.Pager[ClientLocationListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientLocationListResponse]{ + More: func(page ClientLocationListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientLocationListResponse) (ClientLocationListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewLocationListPager") + 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.locationListCreateRequest(ctx, location, options) + }, nil) + if err != nil { + return ClientLocationListResponse{}, err + } + return client.locationListHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// locationListCreateRequest creates the LocationList request. +func (client *Client) locationListCreateRequest(ctx context.Context, location string, options *ClientLocationListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + if options != nil && options.ClusterType != nil { + reqQP.Set("clusterType", *options.ClusterType) + } + if options != nil && options.OfferID != nil { + reqQP.Set("offerId", *options.OfferID) + } + if options != nil && options.PlanID != nil { + reqQP.Set("planId", *options.PlanID) + } + if options != nil && options.PublisherID != nil { + reqQP.Set("publisherId", *options.PublisherID) + } + if options != nil && options.ReleaseTrain != nil { + reqQP.Set("releaseTrain", *options.ReleaseTrain) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// locationListHandleResponse handles the LocationList response. +func (client *Client) locationListHandleResponse(resp *http.Response) (ClientLocationListResponse, error) { + result := ClientLocationListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return ClientLocationListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client_factory.go new file mode 100644 index 000000000000..b71495a6df6c --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/client_factory.go @@ -0,0 +1,42 @@ +// 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 armextensiontypes + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/constants.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/constants.go new file mode 100644 index 000000000000..53610071e8a1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/constants.go @@ -0,0 +1,11 @@ +// 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 armextensiontypes + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes" + moduleVersion = "v0.1.0" +) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/internal.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/internal.go new file mode 100644 index 000000000000..c614f8d5643a --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/internal.go @@ -0,0 +1,85 @@ +// 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" + "reflect" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +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 getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +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/kubernetesconfiguration/armextensiontypes/fake/server.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/server.go new file mode 100644 index 000000000000..4b0c2ef778f2 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/server.go @@ -0,0 +1,613 @@ +// 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/kubernetesconfiguration/armextensiontypes" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// Server is a fake server for instances of the armextensiontypes.Client type. +type Server struct { + // ClusterGetVersion is the fake for method Client.ClusterGetVersion + // HTTP status codes to indicate success: http.StatusOK + ClusterGetVersion func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, versionNumber string, options *armextensiontypes.ClientClusterGetVersionOptions) (resp azfake.Responder[armextensiontypes.ClientClusterGetVersionResponse], errResp azfake.ErrorResponder) + + // NewClusterListVersionsPager is the fake for method Client.NewClusterListVersionsPager + // HTTP status codes to indicate success: http.StatusOK + NewClusterListVersionsPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, options *armextensiontypes.ClientClusterListVersionsOptions) (resp azfake.PagerResponder[armextensiontypes.ClientClusterListVersionsResponse]) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionTypeName string, options *armextensiontypes.ClientGetOptions) (resp azfake.Responder[armextensiontypes.ClientGetResponse], errResp azfake.ErrorResponder) + + // GetVersion is the fake for method Client.GetVersion + // HTTP status codes to indicate success: http.StatusOK + GetVersion func(ctx context.Context, location string, extensionTypeName string, versionNumber string, options *armextensiontypes.ClientGetVersionOptions) (resp azfake.Responder[armextensiontypes.ClientGetVersionResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method Client.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armextensiontypes.ClientListOptions) (resp azfake.PagerResponder[armextensiontypes.ClientListResponse]) + + // NewListVersionsPager is the fake for method Client.NewListVersionsPager + // HTTP status codes to indicate success: http.StatusOK + NewListVersionsPager func(location string, extensionTypeName string, options *armextensiontypes.ClientListVersionsOptions) (resp azfake.PagerResponder[armextensiontypes.ClientListVersionsResponse]) + + // LocationGet is the fake for method Client.LocationGet + // HTTP status codes to indicate success: http.StatusOK + LocationGet func(ctx context.Context, location string, extensionTypeName string, options *armextensiontypes.ClientLocationGetOptions) (resp azfake.Responder[armextensiontypes.ClientLocationGetResponse], errResp azfake.ErrorResponder) + + // NewLocationListPager is the fake for method Client.NewLocationListPager + // HTTP status codes to indicate success: http.StatusOK + NewLocationListPager func(location string, options *armextensiontypes.ClientLocationListOptions) (resp azfake.PagerResponder[armextensiontypes.ClientLocationListResponse]) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armextensiontypes.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + newClusterListVersionsPager: newTracker[azfake.PagerResponder[armextensiontypes.ClientClusterListVersionsResponse]](), + newListPager: newTracker[azfake.PagerResponder[armextensiontypes.ClientListResponse]](), + newListVersionsPager: newTracker[azfake.PagerResponder[armextensiontypes.ClientListVersionsResponse]](), + newLocationListPager: newTracker[azfake.PagerResponder[armextensiontypes.ClientLocationListResponse]](), + } +} + +// ServerTransport connects instances of armextensiontypes.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + newClusterListVersionsPager *tracker[azfake.PagerResponder[armextensiontypes.ClientClusterListVersionsResponse]] + newListPager *tracker[azfake.PagerResponder[armextensiontypes.ClientListResponse]] + newListVersionsPager *tracker[azfake.PagerResponder[armextensiontypes.ClientListVersionsResponse]] + newLocationListPager *tracker[azfake.PagerResponder[armextensiontypes.ClientLocationListResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.ClusterGetVersion": + res.resp, res.err = s.dispatchClusterGetVersion(req) + case "Client.NewClusterListVersionsPager": + res.resp, res.err = s.dispatchNewClusterListVersionsPager(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.GetVersion": + res.resp, res.err = s.dispatchGetVersion(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.NewListVersionsPager": + res.resp, res.err = s.dispatchNewListVersionsPager(req) + case "Client.LocationGet": + res.resp, res.err = s.dispatchLocationGet(req) + case "Client.NewLocationListPager": + res.resp, res.err = s.dispatchNewLocationListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchClusterGetVersion(req *http.Request) (*http.Response, error) { + if s.srv.ClusterGetVersion == nil { + return nil, &nonRetriableError{errors.New("fake for method ClusterGetVersion not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + versionNumberParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionNumber")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ClusterGetVersion(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionTypeNameParam, versionNumberParam, 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).ExtensionTypeVersionForReleaseTrain, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewClusterListVersionsPager(req *http.Request) (*http.Response, error) { + if s.srv.NewClusterListVersionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewClusterListVersionsPager not implemented")} + } + newClusterListVersionsPager := s.newClusterListVersionsPager.get(req) + if newClusterListVersionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + releaseTrainUnescaped, err := url.QueryUnescape(qp.Get("releaseTrain")) + if err != nil { + return nil, err + } + releaseTrainParam := getOptional(releaseTrainUnescaped) + majorVersionUnescaped, err := url.QueryUnescape(qp.Get("majorVersion")) + if err != nil { + return nil, err + } + majorVersionParam := getOptional(majorVersionUnescaped) + showLatestUnescaped, err := url.QueryUnescape(qp.Get("showLatest")) + if err != nil { + return nil, err + } + showLatestParam, err := parseOptional(showLatestUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armextensiontypes.ClientClusterListVersionsOptions + if releaseTrainParam != nil || majorVersionParam != nil || showLatestParam != nil { + options = &armextensiontypes.ClientClusterListVersionsOptions{ + ReleaseTrain: releaseTrainParam, + MajorVersion: majorVersionParam, + ShowLatest: showLatestParam, + } + } + resp := s.srv.NewClusterListVersionsPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionTypeNameParam, options) + newClusterListVersionsPager = &resp + s.newClusterListVersionsPager.add(req, newClusterListVersionsPager) + server.PagerResponderInjectNextLinks(newClusterListVersionsPager, req, func(page *armextensiontypes.ClientClusterListVersionsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newClusterListVersionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newClusterListVersionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newClusterListVersionsPager) { + s.newClusterListVersionsPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionTypeNameParam, 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).ExtensionType, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetVersion(req *http.Request) (*http.Response, error) { + if s.srv.GetVersion == nil { + return nil, &nonRetriableError{errors.New("fake for method GetVersion not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + versionNumberParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionNumber")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetVersion(req.Context(), locationParam, extensionTypeNameParam, versionNumberParam, 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).ExtensionTypeVersionForReleaseTrain, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensionTypes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + publisherIDUnescaped, err := url.QueryUnescape(qp.Get("publisherId")) + if err != nil { + return nil, err + } + publisherIDParam := getOptional(publisherIDUnescaped) + offerIDUnescaped, err := url.QueryUnescape(qp.Get("offerId")) + if err != nil { + return nil, err + } + offerIDParam := getOptional(offerIDUnescaped) + planIDUnescaped, err := url.QueryUnescape(qp.Get("planId")) + if err != nil { + return nil, err + } + planIDParam := getOptional(planIDUnescaped) + releaseTrainUnescaped, err := url.QueryUnescape(qp.Get("releaseTrain")) + if err != nil { + return nil, err + } + releaseTrainParam := getOptional(releaseTrainUnescaped) + var options *armextensiontypes.ClientListOptions + if publisherIDParam != nil || offerIDParam != nil || planIDParam != nil || releaseTrainParam != nil { + options = &armextensiontypes.ClientListOptions{ + PublisherID: publisherIDParam, + OfferID: offerIDParam, + PlanID: planIDParam, + ReleaseTrain: releaseTrainParam, + } + } + resp := s.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armextensiontypes.ClientListResponse, 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 *ServerTransport) dispatchNewListVersionsPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListVersionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVersionsPager not implemented")} + } + newListVersionsPager := s.newListVersionsPager.get(req) + if newListVersionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + releaseTrainUnescaped, err := url.QueryUnescape(qp.Get("releaseTrain")) + if err != nil { + return nil, err + } + releaseTrainParam := getOptional(releaseTrainUnescaped) + clusterTypeUnescaped, err := url.QueryUnescape(qp.Get("clusterType")) + if err != nil { + return nil, err + } + clusterTypeParam := getOptional(clusterTypeUnescaped) + majorVersionUnescaped, err := url.QueryUnescape(qp.Get("majorVersion")) + if err != nil { + return nil, err + } + majorVersionParam := getOptional(majorVersionUnescaped) + showLatestUnescaped, err := url.QueryUnescape(qp.Get("showLatest")) + if err != nil { + return nil, err + } + showLatestParam, err := parseOptional(showLatestUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armextensiontypes.ClientListVersionsOptions + if releaseTrainParam != nil || clusterTypeParam != nil || majorVersionParam != nil || showLatestParam != nil { + options = &armextensiontypes.ClientListVersionsOptions{ + ReleaseTrain: releaseTrainParam, + ClusterType: clusterTypeParam, + MajorVersion: majorVersionParam, + ShowLatest: showLatestParam, + } + } + resp := s.srv.NewListVersionsPager(locationParam, extensionTypeNameParam, options) + newListVersionsPager = &resp + s.newListVersionsPager.add(req, newListVersionsPager) + server.PagerResponderInjectNextLinks(newListVersionsPager, req, func(page *armextensiontypes.ClientListVersionsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVersionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListVersionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVersionsPager) { + s.newListVersionsPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchLocationGet(req *http.Request) (*http.Response, error) { + if s.srv.LocationGet == nil { + return nil, &nonRetriableError{errors.New("fake for method LocationGet not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensionTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + extensionTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.LocationGet(req.Context(), locationParam, extensionTypeNameParam, 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).ExtensionType, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewLocationListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewLocationListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewLocationListPager not implemented")} + } + newLocationListPager := s.newLocationListPager.get(req) + if newLocationListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensionTypes` + 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) + } + qp := req.URL.Query() + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + publisherIDUnescaped, err := url.QueryUnescape(qp.Get("publisherId")) + if err != nil { + return nil, err + } + publisherIDParam := getOptional(publisherIDUnescaped) + offerIDUnescaped, err := url.QueryUnescape(qp.Get("offerId")) + if err != nil { + return nil, err + } + offerIDParam := getOptional(offerIDUnescaped) + planIDUnescaped, err := url.QueryUnescape(qp.Get("planId")) + if err != nil { + return nil, err + } + planIDParam := getOptional(planIDUnescaped) + releaseTrainUnescaped, err := url.QueryUnescape(qp.Get("releaseTrain")) + if err != nil { + return nil, err + } + releaseTrainParam := getOptional(releaseTrainUnescaped) + clusterTypeUnescaped, err := url.QueryUnescape(qp.Get("clusterType")) + if err != nil { + return nil, err + } + clusterTypeParam := getOptional(clusterTypeUnescaped) + var options *armextensiontypes.ClientLocationListOptions + if publisherIDParam != nil || offerIDParam != nil || planIDParam != nil || releaseTrainParam != nil || clusterTypeParam != nil { + options = &armextensiontypes.ClientLocationListOptions{ + PublisherID: publisherIDParam, + OfferID: offerIDParam, + PlanID: planIDParam, + ReleaseTrain: releaseTrainParam, + ClusterType: clusterTypeParam, + } + } + resp := s.srv.NewLocationListPager(locationParam, options) + newLocationListPager = &resp + s.newLocationListPager.add(req, newLocationListPager) + server.PagerResponderInjectNextLinks(newLocationListPager, req, func(page *armextensiontypes.ClientLocationListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newLocationListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newLocationListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newLocationListPager) { + s.newLocationListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/server_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/server_factory.go new file mode 100644 index 000000000000..a83ba7526fc3 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/fake/server_factory.go @@ -0,0 +1,73 @@ +// 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 armextensiontypes.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armextensiontypes.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 armextensiontypes.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.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/kubernetesconfiguration/armextensiontypes/go.mod b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/go.mod new file mode 100644 index 000000000000..e23cde3f7d3d --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/go.sum b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models.go new file mode 100644 index 000000000000..a6d435c30090 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models.go @@ -0,0 +1,151 @@ +// 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 armextensiontypes + +// ClusterScopeSettings - Extension scope settings +type ClusterScopeSettings struct { + // Extension scope settings + Properties *ClusterScopeSettingsProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ClusterScopeSettingsProperties - Extension scope settings +type ClusterScopeSettingsProperties struct { + // Describes if multiple instances of the extension are allowed + AllowMultipleInstances *bool + + // Default extension release namespace + DefaultReleaseNamespace *string +} + +// ExtensionType - The Extension Type object. +type ExtensionType struct { + Properties *ExtensionTypeProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +type ExtensionTypeProperties struct { + // Description of the extension type + Description *string + + // Should an identity for this cluster resource be created + IsManagedIdentityRequired *bool + + // Is this Extension Type a system extension. + IsSystemExtension *bool + + // Plan information only for the Marketplace Extension Type. + PlanInfo *ExtensionTypePropertiesPlanInfo + + // Name of the publisher for the Extension Type + Publisher *string + + // Cluster Types supported for this Extension Type. + SupportedClusterTypes []*string + + // Supported Kubernetes Scopes for this Extension Type. + SupportedScopes *ExtensionTypePropertiesSupportedScopes +} + +// ExtensionTypePropertiesPlanInfo - Plan information only for the Marketplace Extension Type. +type ExtensionTypePropertiesPlanInfo struct { + // Offer or Product ID of the Marketplace Extension Type. + OfferID *string + + // Plan ID of the Marketplace Extension Type. + PlanID *string + + // Publisher ID of the Marketplace Extension Type. + PublisherID *string +} + +// ExtensionTypePropertiesSupportedScopes - Supported Kubernetes Scopes for this Extension Type. +type ExtensionTypePropertiesSupportedScopes struct { + // Extension scope settings + ClusterScopeSettings *ClusterScopeSettings + + // The default scope of the extension type. This scope will be used if the user does not provide a scope while creating an + // extension. + DefaultScope *string +} + +// ExtensionTypeVersionForReleaseTrain - The Extension Type Version object. +type ExtensionTypeVersionForReleaseTrain struct { + Properties *ExtensionTypeVersionForReleaseTrainProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +type ExtensionTypeVersionForReleaseTrainProperties struct { + // A list of supported cluster types for this version of the Extension Type + SupportedClusterTypes []*string + + // The list of supported Kubernetes cluster versions for this extension type + UnsupportedKubernetesVersions *ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions + + // The version number for the extension type + Version *string +} + +// ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions - The list of supported Kubernetes cluster versions +// for this extension type +type ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions struct { + Appliances []*ExtensionTypeVersionUnsupportedKubernetesMatrixItem + ConnectedCluster []*ExtensionTypeVersionUnsupportedKubernetesMatrixItem + ManagedCluster []*ExtensionTypeVersionUnsupportedKubernetesMatrixItem + ProvisionedCluster []*ExtensionTypeVersionUnsupportedKubernetesMatrixItem +} + +// ExtensionTypeVersionUnsupportedKubernetesMatrixItem - The list of Kubernetes Distribution and Versions that are not supported +// by this version of this Extension Type +type ExtensionTypeVersionUnsupportedKubernetesMatrixItem struct { + // The list of Kubernetes Cluster Distribution Names not supported + Distributions []*string + + // The list of Kubernetes Versions not supported by the list of Kubernetes Cluster Distribution names in this object + UnsupportedVersions []*string +} + +// ExtensionTypeVersionsList - List Extension Type Versions. It contains a list of ExtensionTypeVersionForReleaseTrain objects. +type ExtensionTypeVersionsList struct { + // READ-ONLY; URL to get the next set of extension objects, if any. + NextLink *string + + // READ-ONLY; List of Extension Type Versions for an Extension Type in a Release Train. + Value []*ExtensionTypeVersionForReleaseTrain +} + +// List Extension Types. It contains a list of ExtensionType objects and a URL link to get the next set of results. +type List struct { + // READ-ONLY; URL to get the next set of extension type objects, if any. + NextLink *string + + // READ-ONLY; List of Extension Types. + Value []*ExtensionType +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models_serde.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models_serde.go new file mode 100644 index 000000000000..ffc7cb2594c4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/models_serde.go @@ -0,0 +1,465 @@ +// 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 armextensiontypes + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ClusterScopeSettings. +func (c ClusterScopeSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterScopeSettings. +func (c *ClusterScopeSettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterScopeSettingsProperties. +func (c ClusterScopeSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowMultipleInstances", c.AllowMultipleInstances) + populate(objectMap, "defaultReleaseNamespace", c.DefaultReleaseNamespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterScopeSettingsProperties. +func (c *ClusterScopeSettingsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowMultipleInstances": + err = unpopulate(val, "AllowMultipleInstances", &c.AllowMultipleInstances) + delete(rawMsg, key) + case "defaultReleaseNamespace": + err = unpopulate(val, "DefaultReleaseNamespace", &c.DefaultReleaseNamespace) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionType. +func (e ExtensionType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionType. +func (e *ExtensionType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeProperties. +func (e ExtensionTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", e.Description) + populate(objectMap, "isManagedIdentityRequired", e.IsManagedIdentityRequired) + populate(objectMap, "isSystemExtension", e.IsSystemExtension) + populate(objectMap, "planInfo", e.PlanInfo) + populate(objectMap, "publisher", e.Publisher) + populate(objectMap, "supportedClusterTypes", e.SupportedClusterTypes) + populate(objectMap, "supportedScopes", e.SupportedScopes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeProperties. +func (e *ExtensionTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "isManagedIdentityRequired": + err = unpopulate(val, "IsManagedIdentityRequired", &e.IsManagedIdentityRequired) + delete(rawMsg, key) + case "isSystemExtension": + err = unpopulate(val, "IsSystemExtension", &e.IsSystemExtension) + delete(rawMsg, key) + case "planInfo": + err = unpopulate(val, "PlanInfo", &e.PlanInfo) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &e.Publisher) + delete(rawMsg, key) + case "supportedClusterTypes": + err = unpopulate(val, "SupportedClusterTypes", &e.SupportedClusterTypes) + delete(rawMsg, key) + case "supportedScopes": + err = unpopulate(val, "SupportedScopes", &e.SupportedScopes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypePropertiesPlanInfo. +func (e ExtensionTypePropertiesPlanInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerId", e.OfferID) + populate(objectMap, "planId", e.PlanID) + populate(objectMap, "publisherId", e.PublisherID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypePropertiesPlanInfo. +func (e *ExtensionTypePropertiesPlanInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "offerId": + err = unpopulate(val, "OfferID", &e.OfferID) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &e.PlanID) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &e.PublisherID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypePropertiesSupportedScopes. +func (e ExtensionTypePropertiesSupportedScopes) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterScopeSettings", e.ClusterScopeSettings) + populate(objectMap, "defaultScope", e.DefaultScope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypePropertiesSupportedScopes. +func (e *ExtensionTypePropertiesSupportedScopes) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterScopeSettings": + err = unpopulate(val, "ClusterScopeSettings", &e.ClusterScopeSettings) + delete(rawMsg, key) + case "defaultScope": + err = unpopulate(val, "DefaultScope", &e.DefaultScope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeVersionForReleaseTrain. +func (e ExtensionTypeVersionForReleaseTrain) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeVersionForReleaseTrain. +func (e *ExtensionTypeVersionForReleaseTrain) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeVersionForReleaseTrainProperties. +func (e ExtensionTypeVersionForReleaseTrainProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "supportedClusterTypes", e.SupportedClusterTypes) + populate(objectMap, "unsupportedKubernetesVersions", e.UnsupportedKubernetesVersions) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeVersionForReleaseTrainProperties. +func (e *ExtensionTypeVersionForReleaseTrainProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "supportedClusterTypes": + err = unpopulate(val, "SupportedClusterTypes", &e.SupportedClusterTypes) + delete(rawMsg, key) + case "unsupportedKubernetesVersions": + err = unpopulate(val, "UnsupportedKubernetesVersions", &e.UnsupportedKubernetesVersions) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &e.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions. +func (e ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliances", e.Appliances) + populate(objectMap, "connectedCluster", e.ConnectedCluster) + populate(objectMap, "managedCluster", e.ManagedCluster) + populate(objectMap, "provisionedCluster", e.ProvisionedCluster) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions. +func (e *ExtensionTypeVersionForReleaseTrainPropertiesUnsupportedKubernetesVersions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliances": + err = unpopulate(val, "Appliances", &e.Appliances) + delete(rawMsg, key) + case "connectedCluster": + err = unpopulate(val, "ConnectedCluster", &e.ConnectedCluster) + delete(rawMsg, key) + case "managedCluster": + err = unpopulate(val, "ManagedCluster", &e.ManagedCluster) + delete(rawMsg, key) + case "provisionedCluster": + err = unpopulate(val, "ProvisionedCluster", &e.ProvisionedCluster) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeVersionUnsupportedKubernetesMatrixItem. +func (e ExtensionTypeVersionUnsupportedKubernetesMatrixItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "distributions", e.Distributions) + populate(objectMap, "unsupportedVersions", e.UnsupportedVersions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeVersionUnsupportedKubernetesMatrixItem. +func (e *ExtensionTypeVersionUnsupportedKubernetesMatrixItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "distributions": + err = unpopulate(val, "Distributions", &e.Distributions) + delete(rawMsg, key) + case "unsupportedVersions": + err = unpopulate(val, "UnsupportedVersions", &e.UnsupportedVersions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionTypeVersionsList. +func (e ExtensionTypeVersionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTypeVersionsList. +func (e *ExtensionTypeVersionsList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type List. +func (l List) 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 List. +func (l *List) UnmarshalJSON(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 +} + +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/kubernetesconfiguration/armextensiontypes/options.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/options.go new file mode 100644 index 000000000000..6fd7edcf0462 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/options.go @@ -0,0 +1,86 @@ +// 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 armextensiontypes + +// ClientClusterGetVersionOptions contains the optional parameters for the Client.ClusterGetVersion method. +type ClientClusterGetVersionOptions struct { + // placeholder for future optional parameters +} + +// ClientClusterListVersionsOptions contains the optional parameters for the Client.NewClusterListVersionsPager method. +type ClientClusterListVersionsOptions struct { + // Filter results by the major version of an extension type + MajorVersion *string + + // Filter results by release train (default value is stable) + ReleaseTrain *string + + // Filter results by only the latest version (based on other query parameters) + ShowLatest *bool +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientGetVersionOptions contains the optional parameters for the Client.GetVersion method. +type ClientGetVersionOptions struct { + // placeholder for future optional parameters +} + +// ClientListOptions contains the optional parameters for the Client.NewListPager method. +type ClientListOptions struct { + // Filter results by Offer or Product ID of a marketplace extension type + OfferID *string + + // Filter results by Plan ID of a marketplace extension type + PlanID *string + + // Filter results by Publisher ID of a marketplace extension type + PublisherID *string + + // Filter results by release train (default value is stable) + ReleaseTrain *string +} + +// ClientListVersionsOptions contains the optional parameters for the Client.NewListVersionsPager method. +type ClientListVersionsOptions struct { + // Filter results by the cluster type for extension types + ClusterType *string + + // Filter results by the major version of an extension type + MajorVersion *string + + // Filter results by release train (default value is stable) + ReleaseTrain *string + + // Filter results by only the latest version (based on other query parameters) + ShowLatest *bool +} + +// ClientLocationGetOptions contains the optional parameters for the Client.LocationGet method. +type ClientLocationGetOptions struct { + // placeholder for future optional parameters +} + +// ClientLocationListOptions contains the optional parameters for the Client.NewLocationListPager method. +type ClientLocationListOptions struct { + // Filter results by the cluster type for extension types + ClusterType *string + + // Filter results by Offer or Product ID of a marketplace extension type + OfferID *string + + // Filter results by Plan ID of a marketplace extension type + PlanID *string + + // Filter results by Publisher ID of a marketplace extension type + PublisherID *string + + // Filter results by release train (default value is stable) + ReleaseTrain *string +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/responses.go b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/responses.go new file mode 100644 index 000000000000..4a62e45374b7 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armextensiontypes/responses.go @@ -0,0 +1,54 @@ +// 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 armextensiontypes + +// ClientClusterGetVersionResponse contains the response from method Client.ClusterGetVersion. +type ClientClusterGetVersionResponse struct { + // The Extension Type Version object. + ExtensionTypeVersionForReleaseTrain +} + +// ClientClusterListVersionsResponse contains the response from method Client.NewClusterListVersionsPager. +type ClientClusterListVersionsResponse struct { + // List Extension Type Versions. It contains a list of ExtensionTypeVersionForReleaseTrain objects. + ExtensionTypeVersionsList +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // The Extension Type object. + ExtensionType +} + +// ClientGetVersionResponse contains the response from method Client.GetVersion. +type ClientGetVersionResponse struct { + // The Extension Type Version object. + ExtensionTypeVersionForReleaseTrain +} + +// ClientListResponse contains the response from method Client.NewListPager. +type ClientListResponse struct { + // List Extension Types. It contains a list of ExtensionType objects and a URL link to get the next set of results. + List +} + +// ClientListVersionsResponse contains the response from method Client.NewListVersionsPager. +type ClientListVersionsResponse struct { + // List Extension Type Versions. It contains a list of ExtensionTypeVersionForReleaseTrain objects. + ExtensionTypeVersionsList +} + +// ClientLocationGetResponse contains the response from method Client.LocationGet. +type ClientLocationGetResponse struct { + // The Extension Type object. + ExtensionType +} + +// ClientLocationListResponse contains the response from method Client.NewLocationListPager. +type ClientLocationListResponse struct { + // List Extension Types. It contains a list of ExtensionType objects and a URL link to get the next set of results. + List +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/CHANGELOG.md b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/CHANGELOG.md new file mode 100644 index 000000000000..85dc26073b47 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-13) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations` 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/kubernetesconfiguration/armfluxconfigurations/LICENSE.txt b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/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/kubernetesconfiguration/armfluxconfigurations/README.md b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/README.md new file mode 100644 index 000000000000..d9c823be84e2 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/README.md @@ -0,0 +1,90 @@ +# Azure Kubernetesconfiguration Module for Go + +The `armfluxconfigurations` module provides operations for working with Azure Kubernetesconfiguration. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations) + +# 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 Kubernetesconfiguration module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetesconfiguration. 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 Kubernetesconfiguration 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 := armfluxconfigurations.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 := armfluxconfigurations.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.NewClient() +``` + +## 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 `Kubernetesconfiguration` 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/kubernetesconfiguration/armfluxconfigurations/autorest.md b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/autorest.md new file mode 100644 index 000000000000..c06f3295ebc3 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/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/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/fluxConfigurations/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/fluxConfigurations/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/build.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/build.go new file mode 100644 index 000000000000..f39cec687f3b --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/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/kubernetesconfiguration/armfluxconfigurations + +package armfluxconfigurations diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/ci.yml b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/ci.yml new file mode 100644 index 000000000000..351e49c28776 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/ci.yml @@ -0,0 +1,27 @@ +# 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/kubernetesconfiguration/armfluxconfigurations/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/kubernetesconfiguration/armfluxconfigurations' diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client.go new file mode 100644 index 000000000000..3f9731faf32d --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client.go @@ -0,0 +1,486 @@ +// 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 armfluxconfigurations + +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" + "strconv" + "strings" +) + +// Client contains the methods for the FluxConfigurations group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a new Kubernetes Flux Configuration. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - fluxConfigurationName - Name of the Flux Configuration. +// - fluxConfiguration - Properties necessary to Create a FluxConfiguration. +// - options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration FluxConfiguration, options *ClientBeginCreateOrUpdateOptions) (*runtime.Poller[ClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfiguration, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a new Kubernetes Flux Configuration. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration FluxConfiguration, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfiguration, 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 *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration FluxConfiguration, _ *ClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if fluxConfigurationName == "" { + return nil, errors.New("parameter fluxConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fluxConfigurationName}", url.PathEscape(fluxConfigurationName)) + 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", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, fluxConfiguration); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync from the +// source repo. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - fluxConfigurationName - Name of the Flux Configuration. +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync from the source +// repo. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *ClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *ClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if fluxConfigurationName == "" { + return nil, errors.New("parameter fluxConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fluxConfigurationName}", url.PathEscape(fluxConfigurationName)) + 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", "2025-04-01") + if options != nil && options.ForceDelete != nil { + reqQP.Set("forceDelete", strconv.FormatBool(*options.ForceDelete)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets details of the Flux Configuration. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - fluxConfigurationName - Name of the Flux Configuration. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if fluxConfigurationName == "" { + return nil, errors.New("parameter fluxConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fluxConfigurationName}", url.PathEscape(fluxConfigurationName)) + 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", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FluxConfiguration); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all Flux Configurations. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. +func (client *Client) NewListPager(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ + More: func(page ClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListResponse) (ClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) + if err != nil { + return ClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, _ *ClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *Client) listHandleResponse(resp *http.Response) (ClientListResponse, error) { + result := ClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return ClientListResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update an existing Kubernetes Flux Configuration. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - fluxConfigurationName - Name of the Flux Configuration. +// - fluxConfigurationPatch - Properties to Patch in an existing Flux Configuration. +// - options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch FluxConfigurationPatch, options *ClientBeginUpdateOptions) (*runtime.Poller[ClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfigurationPatch, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update an existing Kubernetes Flux Configuration. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +func (client *Client) update(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch FluxConfigurationPatch, options *ClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfigurationPatch, 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 *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch FluxConfigurationPatch, _ *ClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if fluxConfigurationName == "" { + return nil, errors.New("parameter fluxConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fluxConfigurationName}", url.PathEscape(fluxConfigurationName)) + 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", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, fluxConfigurationPatch); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client_factory.go new file mode 100644 index 000000000000..7cb4f37113e5 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/client_factory.go @@ -0,0 +1,50 @@ +// 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 armfluxconfigurations + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewFluxConfigOperationStatusClient creates a new instance of FluxConfigOperationStatusClient. +func (c *ClientFactory) NewFluxConfigOperationStatusClient() *FluxConfigOperationStatusClient { + return &FluxConfigOperationStatusClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/constants.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/constants.go new file mode 100644 index 000000000000..1c746d9869a5 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/constants.go @@ -0,0 +1,151 @@ +// 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 armfluxconfigurations + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// FluxComplianceState - Compliance state of the cluster object. +type FluxComplianceState string + +const ( + FluxComplianceStateCompliant FluxComplianceState = "Compliant" + FluxComplianceStateNonCompliant FluxComplianceState = "Non-Compliant" + FluxComplianceStatePending FluxComplianceState = "Pending" + FluxComplianceStateSuspended FluxComplianceState = "Suspended" + FluxComplianceStateUnknown FluxComplianceState = "Unknown" +) + +// PossibleFluxComplianceStateValues returns the possible values for the FluxComplianceState const type. +func PossibleFluxComplianceStateValues() []FluxComplianceState { + return []FluxComplianceState{ + FluxComplianceStateCompliant, + FluxComplianceStateNonCompliant, + FluxComplianceStatePending, + FluxComplianceStateSuspended, + FluxComplianceStateUnknown, + } +} + +// OperationType - The operation to be performed on the selected layer. The default value is 'extract', but it can be set +// to 'copy'. +type OperationType string + +const ( + OperationTypeCopy OperationType = "copy" + OperationTypeExtract OperationType = "extract" +) + +// PossibleOperationTypeValues returns the possible values for the OperationType const type. +func PossibleOperationTypeValues() []OperationType { + return []OperationType{ + OperationTypeCopy, + OperationTypeExtract, + } +} + +// ProviderType - Name of the provider used for authentication. +type ProviderType string + +const ( + // ProviderTypeAzure - Azure provider can be used to authenticate to Azure DevOps repositories using Managed Identity. + ProviderTypeAzure ProviderType = "Azure" + // ProviderTypeGeneric - Generic is the default provider that indicates secret-based authentication mechanism. + ProviderTypeGeneric ProviderType = "Generic" + // ProviderTypeGitHub - GitHub provider can be used to authenticate + ProviderTypeGitHub ProviderType = "GitHub" +) + +// PossibleProviderTypeValues returns the possible values for the ProviderType const type. +func PossibleProviderTypeValues() []ProviderType { + return []ProviderType{ + ProviderTypeAzure, + ProviderTypeGeneric, + ProviderTypeGitHub, + } +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ScopeType - Scope at which the configuration will be installed. +type ScopeType string + +const ( + ScopeTypeCluster ScopeType = "cluster" + ScopeTypeNamespace ScopeType = "namespace" +) + +// PossibleScopeTypeValues returns the possible values for the ScopeType const type. +func PossibleScopeTypeValues() []ScopeType { + return []ScopeType{ + ScopeTypeCluster, + ScopeTypeNamespace, + } +} + +// SourceKindType - Source Kind to pull the configuration data from. +type SourceKindType string + +const ( + SourceKindTypeAzureBlob SourceKindType = "AzureBlob" + SourceKindTypeBucket SourceKindType = "Bucket" + SourceKindTypeGitRepository SourceKindType = "GitRepository" + SourceKindTypeOCIRepository SourceKindType = "OCIRepository" +) + +// PossibleSourceKindTypeValues returns the possible values for the SourceKindType const type. +func PossibleSourceKindTypeValues() []SourceKindType { + return []SourceKindType{ + SourceKindTypeAzureBlob, + SourceKindTypeBucket, + SourceKindTypeGitRepository, + SourceKindTypeOCIRepository, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/fluxconfigoperationstatus_server.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/fluxconfigoperationstatus_server.go new file mode 100644 index 000000000000..217ef40694c7 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/fluxconfigoperationstatus_server.go @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations" + "net/http" + "net/url" + "regexp" +) + +// FluxConfigOperationStatusServer is a fake server for instances of the armfluxconfigurations.FluxConfigOperationStatusClient type. +type FluxConfigOperationStatusServer struct { + // Get is the fake for method FluxConfigOperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, operationID string, options *armfluxconfigurations.FluxConfigOperationStatusClientGetOptions) (resp azfake.Responder[armfluxconfigurations.FluxConfigOperationStatusClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewFluxConfigOperationStatusServerTransport creates a new instance of FluxConfigOperationStatusServerTransport with the provided implementation. +// The returned FluxConfigOperationStatusServerTransport instance is connected to an instance of armfluxconfigurations.FluxConfigOperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFluxConfigOperationStatusServerTransport(srv *FluxConfigOperationStatusServer) *FluxConfigOperationStatusServerTransport { + return &FluxConfigOperationStatusServerTransport{srv: srv} +} + +// FluxConfigOperationStatusServerTransport connects instances of armfluxconfigurations.FluxConfigOperationStatusClient to instances of FluxConfigOperationStatusServer. +// Don't use this type directly, use NewFluxConfigOperationStatusServerTransport instead. +type FluxConfigOperationStatusServerTransport struct { + srv *FluxConfigOperationStatusServer +} + +// Do implements the policy.Transporter interface for FluxConfigOperationStatusServerTransport. +func (f *FluxConfigOperationStatusServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return f.dispatchToMethodFake(req, method) +} + +func (f *FluxConfigOperationStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if fluxConfigOperationStatusServerTransportInterceptor != nil { + res.resp, res.err, intercepted = fluxConfigOperationStatusServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "FluxConfigOperationStatusClient.Get": + res.resp, res.err = f.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (f *FluxConfigOperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, operationIDParam, 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).OperationStatusResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to FluxConfigOperationStatusServerTransport +var fluxConfigOperationStatusServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/internal.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/internal.go new file mode 100644 index 000000000000..0e32a8018fe4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/internal.go @@ -0,0 +1,77 @@ +// 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 result struct { + resp *http.Response + err error +} + +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 parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +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/kubernetesconfiguration/armfluxconfigurations/fake/server.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/server.go new file mode 100644 index 000000000000..68772a477d91 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/server.go @@ -0,0 +1,410 @@ +// 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/kubernetesconfiguration/armfluxconfigurations" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// Server is a fake server for instances of the armfluxconfigurations.Client type. +type Server struct { + // BeginCreateOrUpdate is the fake for method Client.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration armfluxconfigurations.FluxConfiguration, options *armfluxconfigurations.ClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armfluxconfigurations.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method Client.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *armfluxconfigurations.ClientBeginDeleteOptions) (resp azfake.PollerResponder[armfluxconfigurations.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *armfluxconfigurations.ClientGetOptions) (resp azfake.Responder[armfluxconfigurations.ClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method Client.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armfluxconfigurations.ClientListOptions) (resp azfake.PagerResponder[armfluxconfigurations.ClientListResponse]) + + // BeginUpdate is the fake for method Client.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch armfluxconfigurations.FluxConfigurationPatch, options *armfluxconfigurations.ClientBeginUpdateOptions) (resp azfake.PollerResponder[armfluxconfigurations.ClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armfluxconfigurations.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armfluxconfigurations.ClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armfluxconfigurations.ClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armfluxconfigurations.ClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armfluxconfigurations.ClientUpdateResponse]](), + } +} + +// ServerTransport connects instances of armfluxconfigurations.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginCreateOrUpdate *tracker[azfake.PollerResponder[armfluxconfigurations.ClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armfluxconfigurations.ClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armfluxconfigurations.ClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armfluxconfigurations.ClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginCreateOrUpdate": + res.resp, res.err = s.dispatchBeginCreateOrUpdate(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfluxconfigurations.FluxConfiguration](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, 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 *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + forceDeleteUnescaped, err := url.QueryUnescape(qp.Get("forceDelete")) + if err != nil { + return nil, err + } + forceDeleteParam, err := parseOptional(forceDeleteUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armfluxconfigurations.ClientBeginDeleteOptions + if forceDeleteParam != nil { + options = &armfluxconfigurations.ClientBeginDeleteOptions{ + ForceDelete: forceDeleteParam, + } + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, options) + 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.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, 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).FluxConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armfluxconfigurations.ClientListResponse, 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 *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfluxconfigurations.FluxConfigurationPatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, 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 +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/server_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/server_factory.go new file mode 100644 index 000000000000..1cd51c62a4f4 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fake/server_factory.go @@ -0,0 +1,82 @@ +// 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 armfluxconfigurations.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // FluxConfigOperationStatusServer contains the fakes for client FluxConfigOperationStatusClient + FluxConfigOperationStatusServer FluxConfigOperationStatusServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armfluxconfigurations.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 armfluxconfigurations.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trFluxConfigOperationStatusServer *FluxConfigOperationStatusServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "FluxConfigOperationStatusClient": + initServer(s, &s.trFluxConfigOperationStatusServer, func() *FluxConfigOperationStatusServerTransport { + return NewFluxConfigOperationStatusServerTransport(&s.srv.FluxConfigOperationStatusServer) + }) + resp, err = s.trFluxConfigOperationStatusServer.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/kubernetesconfiguration/armfluxconfigurations/fluxconfigoperationstatus_client.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fluxconfigoperationstatus_client.go new file mode 100644 index 000000000000..20a8016af567 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/fluxconfigoperationstatus_client.go @@ -0,0 +1,127 @@ +// 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 armfluxconfigurations + +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" +) + +// FluxConfigOperationStatusClient contains the methods for the FluxConfigOperationStatus group. +// Don't use this type directly, use NewFluxConfigOperationStatusClient() instead. +type FluxConfigOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFluxConfigOperationStatusClient creates a new instance of FluxConfigOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFluxConfigOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FluxConfigOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FluxConfigOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get Async Operation status +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - clusterRp - The Kubernetes cluster RP - i.e. Microsoft.ContainerService, Microsoft.Kubernetes, Microsoft.HybridContainerService. +// - clusterResourceName - The Kubernetes cluster resource name - i.e. managedClusters, connectedClusters, provisionedClusters, +// appliances. +// - clusterName - The name of the kubernetes cluster. +// - fluxConfigurationName - Name of the Flux Configuration. +// - operationID - operation Id +// - options - FluxConfigOperationStatusClientGetOptions contains the optional parameters for the FluxConfigOperationStatusClient.Get +// method. +func (client *FluxConfigOperationStatusClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, operationID string, options *FluxConfigOperationStatusClientGetOptions) (FluxConfigOperationStatusClientGetResponse, error) { + var err error + const operationName = "FluxConfigOperationStatusClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, operationID, options) + if err != nil { + return FluxConfigOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FluxConfigOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FluxConfigOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *FluxConfigOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, operationID string, _ *FluxConfigOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterRp == "" { + return nil, errors.New("parameter clusterRp cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterRp}", url.PathEscape(clusterRp)) + if clusterResourceName == "" { + return nil, errors.New("parameter clusterResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterResourceName}", url.PathEscape(clusterResourceName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if fluxConfigurationName == "" { + return nil, errors.New("parameter fluxConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fluxConfigurationName}", url.PathEscape(fluxConfigurationName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FluxConfigOperationStatusClient) getHandleResponse(resp *http.Response) (FluxConfigOperationStatusClientGetResponse, error) { + result := FluxConfigOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatusResult); err != nil { + return FluxConfigOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.mod b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.mod new file mode 100644 index 000000000000..4ad72b4b60aa --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.sum b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models.go new file mode 100644 index 000000000000..d2a883a4d8b8 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models.go @@ -0,0 +1,810 @@ +// 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 armfluxconfigurations + +import "time" + +// AzureBlobDefinition - Parameters to reconcile to the AzureBlob source kind type. +type AzureBlobDefinition struct { + // The account key (shared key) to access the storage account + AccountKey *string + + // The Azure Blob container name to sync from the url endpoint for the flux configuration. + ContainerName *string + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // Parameters to authenticate using a Managed Identity. + ManagedIdentity *ManagedIdentityDefinition + + // The Shared Access token to access the storage container + SasToken *string + + // Parameters to authenticate using Service Principal. + ServicePrincipal *ServicePrincipalDefinition + + // The interval at which to re-reconcile the cluster Azure Blob source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster Azure Blob source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration Azure Blob storage account. + URL *string +} + +// AzureBlobPatchDefinition - Parameters to reconcile to the AzureBlob source kind type. +type AzureBlobPatchDefinition struct { + // The account key (shared key) to access the storage account + AccountKey *string + + // The Azure Blob container name to sync from the url endpoint for the flux configuration. + ContainerName *string + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // Parameters to authenticate using a Managed Identity. + ManagedIdentity *ManagedIdentityPatchDefinition + + // The Shared Access token to access the storage container + SasToken *string + + // Parameters to authenticate using Service Principal. + ServicePrincipal *ServicePrincipalPatchDefinition + + // The interval at which to re-reconcile the cluster Azure Blob source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster Azure Blob source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration Azure Blob storage account. + URL *string +} + +// BucketDefinition - Parameters to reconcile to the Bucket source kind type. +type BucketDefinition struct { + // Plaintext access key used to securely access the S3 bucket + AccessKey *string + + // The bucket name to sync from the url endpoint for the flux configuration. + BucketName *string + + // Specify whether to use insecure communication when puling data from the S3 bucket. + Insecure *bool + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // The interval at which to re-reconcile the cluster bucket source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster bucket source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration S3 bucket. + URL *string +} + +// BucketPatchDefinition - Parameters to reconcile to the Bucket source kind type. +type BucketPatchDefinition struct { + // Plaintext access key used to securely access the S3 bucket + AccessKey *string + + // The bucket name to sync from the url endpoint for the flux configuration. + BucketName *string + + // Specify whether to use insecure communication when puling data from the S3 bucket. + Insecure *bool + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // The interval at which to re-reconcile the cluster bucket source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster bucket source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration S3 bucket. + URL *string +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// FluxConfiguration - The Flux Configuration object returned in Get & Put response. +type FluxConfiguration struct { + // Properties to create a Flux Configuration resource + Properties *FluxConfigurationProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// FluxConfigurationPatch - The Flux Configuration Patch Request object. +type FluxConfigurationPatch struct { + // Updatable properties of an Flux Configuration Patch Request + Properties *FluxConfigurationPatchProperties +} + +// FluxConfigurationPatchProperties - Updatable properties of an Flux Configuration Patch Request +type FluxConfigurationPatchProperties struct { + // Parameters to reconcile to the AzureBlob source kind type. + AzureBlob *AzureBlobPatchDefinition + + // Parameters to reconcile to the Bucket source kind type. + Bucket *BucketPatchDefinition + + // Key-value pairs of protected configuration settings for the configuration + ConfigurationProtectedSettings map[string]*string + + // Parameters to reconcile to the GitRepository source kind type. + GitRepository *GitRepositoryPatchDefinition + + // Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. + Kustomizations map[string]*KustomizationPatchDefinition + + // Parameters to reconcile to the OCIRepository source kind type. + OciRepository *OCIRepositoryPatchDefinition + + // Source Kind to pull the configuration data from. + SourceKind *SourceKindType + + // Whether this configuration should suspend its reconciliation of its kustomizations and sources. + Suspend *bool +} + +// FluxConfigurationProperties - Properties to create a Flux Configuration resource +type FluxConfigurationProperties struct { + // Parameters to reconcile to the AzureBlob source kind type. + AzureBlob *AzureBlobDefinition + + // Parameters to reconcile to the Bucket source kind type. + Bucket *BucketDefinition + + // Key-value pairs of protected configuration settings for the configuration + ConfigurationProtectedSettings map[string]*string + + // Parameters to reconcile to the GitRepository source kind type. + GitRepository *GitRepositoryDefinition + + // Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster. + Kustomizations map[string]*KustomizationDefinition + + // The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and + // period only. + Namespace *string + + // Parameters to reconcile to the OCIRepository source kind type. + OciRepository *OCIRepositoryDefinition + + // Maximum duration to wait for flux configuration reconciliation. E.g PT1H, PT5M, P1D + ReconciliationWaitDuration *string + + // Scope at which the operator will be installed. + Scope *ScopeType + + // Source Kind to pull the configuration data from. + SourceKind *SourceKindType + + // Whether this configuration should suspend its reconciliation of its kustomizations and sources. + Suspend *bool + + // Whether flux configuration deployment should wait for cluster to reconcile the kustomizations. + WaitForReconciliation *bool + + // READ-ONLY; Combined status of the Flux Kubernetes resources created by the fluxConfiguration or created by the managed + // objects. + ComplianceState *FluxComplianceState + + // READ-ONLY; Error message returned to the user in the case of provisioning failure. + ErrorMessage *string + + // READ-ONLY; Status of the creation of the fluxConfiguration. + ProvisioningState *ProvisioningState + + // READ-ONLY; Public Key associated with this fluxConfiguration (either generated within the cluster or provided by the user). + RepositoryPublicKey *string + + // READ-ONLY; Branch and/or SHA of the source commit synced with the cluster. + SourceSyncedCommitID *string + + // READ-ONLY; Datetime the fluxConfiguration synced its source on the cluster. + SourceUpdatedAt *time.Time + + // READ-ONLY; Datetime the fluxConfiguration synced its status on the cluster with Azure. + StatusUpdatedAt *time.Time + + // READ-ONLY; Statuses of the Flux Kubernetes resources created by the fluxConfiguration or created by the managed objects + // provisioned by the fluxConfiguration. + Statuses []*ObjectStatusDefinition +} + +// GitRepositoryDefinition - Parameters to reconcile to the GitRepository source kind type. +type GitRepositoryDefinition struct { + // Base64-encoded HTTPS certificate authority contents used to access git private git repositories over HTTPS + HTTPSCACert *string + + // Plaintext HTTPS username used to access private git repositories over HTTPS + HTTPSUser *string + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // Name of the provider used for authentication. + Provider *ProviderType + + // The source reference for the GitRepository object. + RepositoryRef *RepositoryRefDefinition + + // Base64-encoded known_hosts value containing public SSH keys required to access private git repositories over SSH + SSHKnownHosts *string + + // The interval at which to re-reconcile the cluster git repository source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster git repository source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration git repository. + URL *string +} + +// GitRepositoryPatchDefinition - Parameters to reconcile to the GitRepository source kind type. +type GitRepositoryPatchDefinition struct { + // Base64-encoded HTTPS certificate authority contents used to access git private git repositories over HTTPS + HTTPSCACert *string + + // Plaintext HTTPS username used to access private git repositories over HTTPS + HTTPSUser *string + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // Name of the provider used for authentication. + Provider *ProviderType + + // The source reference for the GitRepository object. + RepositoryRef *RepositoryRefDefinition + + // Base64-encoded known_hosts value containing public SSH keys required to access private git repositories over SSH + SSHKnownHosts *string + + // The interval at which to re-reconcile the cluster git repository source with the remote. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the cluster git repository source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration git repository. + URL *string +} + +// HelmReleasePropertiesDefinition - Properties for HelmRelease objects +type HelmReleasePropertiesDefinition struct { + // Total number of times that the HelmRelease failed to install or upgrade + FailureCount *int64 + + // The reference to the HelmChart object used as the source to this HelmRelease + HelmChartRef *ObjectReferenceDefinition + + // Number of times that the HelmRelease failed to install + InstallFailureCount *int64 + + // The revision number of the last released object change + LastRevisionApplied *int64 + + // Number of times that the HelmRelease failed to upgrade + UpgradeFailureCount *int64 +} + +// KustomizationDefinition - The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +type KustomizationDefinition struct { + // Specifies other Kustomizations that this Kustomization depends on. This Kustomization will not reconcile until all dependencies + // have completed their reconciliation. + DependsOn []*string + + // Enable/disable re-creating Kubernetes resources on the cluster when patching fails due to an immutable field change. + Force *bool + + // The path in the source reference to reconcile on the cluster. + Path *string + + // Used for variable substitution for this Kustomization after kustomize build. + PostBuild *PostBuildDefinition + + // Enable/disable garbage collections of Kubernetes objects created by this Kustomization. + Prune *bool + + // The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. + RetryIntervalInSeconds *int64 + + // The interval at which to re-reconcile the Kustomization on the cluster. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the Kustomization on the cluster. + TimeoutInSeconds *int64 + + // Enable/disable health check for all Kubernetes objects created by this Kustomization. + Wait *bool + + // READ-ONLY; Name of the Kustomization, matching the key in the Kustomizations object map. + Name *string +} + +// KustomizationPatchDefinition - The Kustomization defining how to reconcile the artifact pulled by the source type on the +// cluster. +type KustomizationPatchDefinition struct { + // Specifies other Kustomizations that this Kustomization depends on. This Kustomization will not reconcile until all dependencies + // have completed their reconciliation. + DependsOn []*string + + // Enable/disable re-creating Kubernetes resources on the cluster when patching fails due to an immutable field change. + Force *bool + + // The path in the source reference to reconcile on the cluster. + Path *string + + // Used for variable substitution for this Kustomization after kustomize build. + PostBuild *PostBuildPatchDefinition + + // Enable/disable garbage collections of Kubernetes objects created by this Kustomization. + Prune *bool + + // The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. + RetryIntervalInSeconds *int64 + + // The interval at which to re-reconcile the Kustomization on the cluster. + SyncIntervalInSeconds *int64 + + // The maximum time to attempt to reconcile the Kustomization on the cluster. + TimeoutInSeconds *int64 + + // Enable/disable health check for all Kubernetes objects created by this Kustomization. + Wait *bool +} + +// LayerSelectorDefinition - Parameters to specify which layer to pull from the OCI artifact. By default, the first layer +// in the artifact is pulled. +type LayerSelectorDefinition struct { + // The first layer matching the specified media type will be used. + MediaType *string + + // The operation to be performed on the selected layer. The default value is 'extract', but it can be set to 'copy'. + Operation *OperationType +} + +// LayerSelectorPatchDefinition - Parameters to specify which layer to pull from the OCI artifact. By default, the first layer +// in the artifact is pulled. +type LayerSelectorPatchDefinition struct { + // The first layer matching the specified media type will be used. + MediaType *string + + // The operation to be performed on the selected layer. The default value is 'extract', but it can be set to 'copy'. + Operation *OperationType +} + +// List - Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link +// to get the next set of results. +type List struct { + // READ-ONLY; URL to get the next set of configuration objects, if any. + NextLink *string + + // READ-ONLY; List of Flux Configurations within a Kubernetes cluster. + Value []*FluxConfiguration +} + +// ManagedIdentityDefinition - Parameters to authenticate using a Managed Identity. +type ManagedIdentityDefinition struct { + // The client Id for authenticating a Managed Identity. + ClientID *string +} + +// ManagedIdentityPatchDefinition - Parameters to authenticate using a Managed Identity. +type ManagedIdentityPatchDefinition struct { + // The client Id for authenticating a Managed Identity. + ClientID *string +} + +// MatchOidcIdentityDefinition - MatchOIDCIdentity defines the criteria for matching the identity while verifying an OCI artifact. +type MatchOidcIdentityDefinition struct { + // The regex pattern to match against to verify the OIDC issuer. + Issuer *string + + // The regex pattern to match against to verify the identity subject. + Subject *string +} + +// MatchOidcIdentityPatchDefinition - MatchOIDCIdentity defines the criteria for matching the identity while verifying an +// OCI artifact. +type MatchOidcIdentityPatchDefinition struct { + // The regex pattern to match against to verify the OIDC issuer. + Issuer *string + + // The regex pattern to match against to verify the identity subject. + Subject *string +} + +// OCIRepositoryDefinition - Parameters to reconcile to the OCIRepository source kind type. +type OCIRepositoryDefinition struct { + // Specify whether to allow connecting to a non-TLS HTTP container registry. + Insecure *bool + + // The layer to be pulled from the OCI artifact. + LayerSelector *LayerSelectorDefinition + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // The source reference for the OCIRepository object. + RepositoryRef *OCIRepositoryRefDefinition + + // The service account name to authenticate with the OCI repository. + ServiceAccountName *string + + // The interval at which to re-reconcile the cluster OCI repository source with the remote. + SyncIntervalInSeconds *int64 + + // Parameters to authenticate using TLS config for OCI repository. + TLSConfig *TLSConfigDefinition + + // The maximum time to attempt to reconcile the cluster OCI repository source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration OCI repository. + URL *string + + // Specifies whether to use Workload Identity to authenticate with the OCI repository. + UseWorkloadIdentity *bool + + // Verification of the authenticity of an OCI Artifact. + Verify *VerifyDefinition +} + +// OCIRepositoryPatchDefinition - Parameters to reconcile to the OCIRepository source kind type. +type OCIRepositoryPatchDefinition struct { + // Specify whether to allow connecting to a non-TLS HTTP container registry. + Insecure *bool + + // The layer to be pulled from the OCI artifact. + LayerSelector *LayerSelectorPatchDefinition + + // Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided + // configuration secrets. + LocalAuthRef *string + + // The source reference for the OCIRepository object. + RepositoryRef *OCIRepositoryRefPatchDefinition + + // The service account name to authenticate with the OCI repository. + ServiceAccountName *string + + // The interval at which to re-reconcile the cluster OCI repository source with the remote. + SyncIntervalInSeconds *int64 + + // Parameters to authenticate using TLS config for OCI repository. + TLSConfig *TLSConfigPatchDefinition + + // The maximum time to attempt to reconcile the cluster OCI repository source with the remote. + TimeoutInSeconds *int64 + + // The URL to sync for the flux configuration OCI repository. + URL *string + + // Specifies whether to use Workload Identity to authenticate with the OCI repository. + UseWorkloadIdentity *bool + + // Verification of the authenticity of an OCI Artifact. + Verify *VerifyPatchDefinition +} + +// OCIRepositoryRefDefinition - The source reference for the OCIRepository object. +type OCIRepositoryRefDefinition struct { + // The image digest to pull from OCI repository, the value should be in the format ‘sha256:’. This takes precedence over semver. + Digest *string + + // The semver range used to match against OCI repository tags. This takes precedence over tag. + Semver *string + + // The OCI repository image tag name to pull. This defaults to 'latest'. + Tag *string +} + +// OCIRepositoryRefPatchDefinition - The source reference for the OCIRepository object. +type OCIRepositoryRefPatchDefinition struct { + // The image digest to pull from OCI repository, the value should be in the format ‘sha256:’. This takes precedence over semver. + Digest *string + + // The semver range used to match against OCI repository tags. This takes precedence over tag. + Semver *string + + // The OCI repository image tag name to pull. This defaults to 'latest'. + Tag *string +} + +// ObjectReferenceDefinition - Object reference to a Kubernetes object on a cluster +type ObjectReferenceDefinition struct { + // Name of the object + Name *string + + // Namespace of the object + Namespace *string +} + +// ObjectStatusConditionDefinition - Status condition of Kubernetes object +type ObjectStatusConditionDefinition struct { + // Last time this status condition has changed + LastTransitionTime *time.Time + + // A more verbose description of the object status condition + Message *string + + // Reason for the specified status condition type status + Reason *string + + // Status of the Kubernetes object condition type + Status *string + + // Object status condition type for this object + Type *string +} + +// ObjectStatusDefinition - Statuses of objects deployed by the user-specified kustomizations from the git repository. +type ObjectStatusDefinition struct { + // Object reference to the Kustomization that applied this object + AppliedBy *ObjectReferenceDefinition + + // Compliance state of the applied object showing whether the applied object has come into a ready state on the cluster. + ComplianceState *FluxComplianceState + + // Additional properties that are provided from objects of the HelmRelease kind + HelmReleaseProperties *HelmReleasePropertiesDefinition + + // Kind of the applied object + Kind *string + + // Name of the applied object + Name *string + + // Namespace of the applied object + Namespace *string + + // List of Kubernetes object status conditions present on the cluster + StatusConditions []*ObjectStatusConditionDefinition +} + +// OperationStatusResult - The current status of an async operation. +type OperationStatusResult struct { + // REQUIRED; Operation status. + Status *string + + // Fully qualified ID for the async operation. + ID *string + + // Name of the async operation. + Name *string + + // Additional information, if available. + Properties map[string]*string + + // READ-ONLY; If present, details of the operation error. + Error *ErrorDetail +} + +// PostBuildDefinition - The postBuild definitions defining variable substitutions for this Kustomization after kustomize +// build. +type PostBuildDefinition struct { + // Key/value pairs holding the variables to be substituted in this Kustomization. + Substitute map[string]*string + + // Array of ConfigMaps/Secrets from which the variables are substituted for this Kustomization. + SubstituteFrom []*SubstituteFromDefinition +} + +// PostBuildPatchDefinition - The postBuild definitions defining variable substitutions for this Kustomization after kustomize +// build. +type PostBuildPatchDefinition struct { + // Key/value pairs holding the variables to be substituted in this Kustomization. + Substitute map[string]*string + + // Array of ConfigMaps/Secrets from which the variables are substituted for this Kustomization. + SubstituteFrom []*SubstituteFromPatchDefinition +} + +// RepositoryRefDefinition - The source reference for the GitRepository object. +type RepositoryRefDefinition struct { + // The git repository branch name to checkout. + Branch *string + + // The commit SHA to checkout. This value must be combined with the branch name to be valid. This takes precedence over semver. + Commit *string + + // The semver range used to match against git repository tags. This takes precedence over tag. + Semver *string + + // The git repository tag name to checkout. This takes precedence over branch. + Tag *string +} + +// ServicePrincipalDefinition - Parameters to authenticate using Service Principal. +type ServicePrincipalDefinition struct { + // Base64-encoded certificate used to authenticate a Service Principal + ClientCertificate *string + + // The password for the certificate used to authenticate a Service Principal + ClientCertificatePassword *string + + // Specifies whether to include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication + // for the Client Certificate + ClientCertificateSendChain *bool + + // The client Id for authenticating a Service Principal. + ClientID *string + + // The client secret for authenticating a Service Principal + ClientSecret *string + + // The tenant Id for authenticating a Service Principal + TenantID *string +} + +// ServicePrincipalPatchDefinition - Parameters to authenticate using Service Principal. +type ServicePrincipalPatchDefinition struct { + // Base64-encoded certificate used to authenticate a Service Principal + ClientCertificate *string + + // The password for the certificate used to authenticate a Service Principal + ClientCertificatePassword *string + + // Specifies whether to include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication + // for the Client Certificate + ClientCertificateSendChain *bool + + // The client Id for authenticating a Service Principal. + ClientID *string + + // The client secret for authenticating a Service Principal + ClientSecret *string + + // The tenant Id for authenticating a Service Principal + TenantID *string +} + +// SubstituteFromDefinition - Array of ConfigMaps/Secrets from which the variables are substituted for this Kustomization. +type SubstituteFromDefinition struct { + // Define whether it is ConfigMap or Secret that holds the variables to be used in substitution. + Kind *string + + // Name of the ConfigMap/Secret that holds the variables to be used in substitution. + Name *string + + // Set to True to proceed without ConfigMap/Secret, if it is not present. + Optional *bool +} + +// SubstituteFromPatchDefinition - Array of ConfigMaps/Secrets from which the variables are substituted for this Kustomization. +type SubstituteFromPatchDefinition struct { + // Define whether it is ConfigMap or Secret that holds the variables to be used in substitution. + Kind *string + + // Name of the ConfigMap/Secret that holds the variables to be used in substitution. + Name *string + + // Set to True to proceed without ConfigMap/Secret, if it is not present. + Optional *bool +} + +// 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 +} + +// TLSConfigDefinition - Parameters to authenticate using TLS config for OCI repository. +type TLSConfigDefinition struct { + // Base64-encoded CA certificate used to verify the server. + CaCertificate *string + + // Base64-encoded certificate used to authenticate a client with the OCI repository. + ClientCertificate *string + + // Base64-encoded private key used to authenticate a client with the OCI repository. + PrivateKey *string +} + +// TLSConfigPatchDefinition - Parameters to authenticate using TLS config for OCI repository. +type TLSConfigPatchDefinition struct { + // Base64-encoded CA certificate used to verify the server. + CaCertificate *string + + // Base64-encoded certificate used to authenticate a client with the OCI repository. + ClientCertificate *string + + // Base64-encoded private key used to authenticate a client with the OCI repository. + PrivateKey *string +} + +// VerifyDefinition - Parameters to verify the authenticity of an OCI Artifact. +type VerifyDefinition struct { + // Array defining the criteria for matching the identity while verifying an OCI artifact. + MatchOidcIdentity []*MatchOidcIdentityDefinition + + // Verification provider name. + Provider *string + + // An object containing trusted public keys of trusted authors. + VerificationConfig map[string]*string +} + +// VerifyPatchDefinition - Parameters to verify the authenticity of an OCI Artifact. +type VerifyPatchDefinition struct { + // Array defining the criteria for matching the OIDC identity while verifying an OCI artifact. + MatchOidcIdentity []*MatchOidcIdentityPatchDefinition + + // Verification provider name. + Provider *string + + // An object containing trusted public keys of trusted authors. + VerificationConfig map[string]*string +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models_serde.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models_serde.go new file mode 100644 index 000000000000..2410c01a1336 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/models_serde.go @@ -0,0 +1,1881 @@ +// 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 armfluxconfigurations + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AzureBlobDefinition. +func (a AzureBlobDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountKey", a.AccountKey) + populate(objectMap, "containerName", a.ContainerName) + populate(objectMap, "localAuthRef", a.LocalAuthRef) + populate(objectMap, "managedIdentity", a.ManagedIdentity) + populate(objectMap, "sasToken", a.SasToken) + populate(objectMap, "servicePrincipal", a.ServicePrincipal) + populate(objectMap, "syncIntervalInSeconds", a.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", a.TimeoutInSeconds) + populate(objectMap, "url", a.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureBlobDefinition. +func (a *AzureBlobDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountKey": + err = unpopulate(val, "AccountKey", &a.AccountKey) + delete(rawMsg, key) + case "containerName": + err = unpopulate(val, "ContainerName", &a.ContainerName) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &a.LocalAuthRef) + delete(rawMsg, key) + case "managedIdentity": + err = unpopulate(val, "ManagedIdentity", &a.ManagedIdentity) + delete(rawMsg, key) + case "sasToken": + err = unpopulate(val, "SasToken", &a.SasToken) + delete(rawMsg, key) + case "servicePrincipal": + err = unpopulate(val, "ServicePrincipal", &a.ServicePrincipal) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &a.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &a.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &a.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureBlobPatchDefinition. +func (a AzureBlobPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountKey", a.AccountKey) + populate(objectMap, "containerName", a.ContainerName) + populate(objectMap, "localAuthRef", a.LocalAuthRef) + populate(objectMap, "managedIdentity", a.ManagedIdentity) + populate(objectMap, "sasToken", a.SasToken) + populate(objectMap, "servicePrincipal", a.ServicePrincipal) + populate(objectMap, "syncIntervalInSeconds", a.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", a.TimeoutInSeconds) + populate(objectMap, "url", a.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureBlobPatchDefinition. +func (a *AzureBlobPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountKey": + err = unpopulate(val, "AccountKey", &a.AccountKey) + delete(rawMsg, key) + case "containerName": + err = unpopulate(val, "ContainerName", &a.ContainerName) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &a.LocalAuthRef) + delete(rawMsg, key) + case "managedIdentity": + err = unpopulate(val, "ManagedIdentity", &a.ManagedIdentity) + delete(rawMsg, key) + case "sasToken": + err = unpopulate(val, "SasToken", &a.SasToken) + delete(rawMsg, key) + case "servicePrincipal": + err = unpopulate(val, "ServicePrincipal", &a.ServicePrincipal) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &a.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &a.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &a.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BucketDefinition. +func (b BucketDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessKey", b.AccessKey) + populate(objectMap, "bucketName", b.BucketName) + populate(objectMap, "insecure", b.Insecure) + populate(objectMap, "localAuthRef", b.LocalAuthRef) + populate(objectMap, "syncIntervalInSeconds", b.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", b.TimeoutInSeconds) + populate(objectMap, "url", b.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BucketDefinition. +func (b *BucketDefinition) UnmarshalJSON(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 "accessKey": + err = unpopulate(val, "AccessKey", &b.AccessKey) + delete(rawMsg, key) + case "bucketName": + err = unpopulate(val, "BucketName", &b.BucketName) + delete(rawMsg, key) + case "insecure": + err = unpopulate(val, "Insecure", &b.Insecure) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &b.LocalAuthRef) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &b.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &b.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &b.URL) + 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 BucketPatchDefinition. +func (b BucketPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessKey", b.AccessKey) + populate(objectMap, "bucketName", b.BucketName) + populate(objectMap, "insecure", b.Insecure) + populate(objectMap, "localAuthRef", b.LocalAuthRef) + populate(objectMap, "syncIntervalInSeconds", b.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", b.TimeoutInSeconds) + populate(objectMap, "url", b.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BucketPatchDefinition. +func (b *BucketPatchDefinition) UnmarshalJSON(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 "accessKey": + err = unpopulate(val, "AccessKey", &b.AccessKey) + delete(rawMsg, key) + case "bucketName": + err = unpopulate(val, "BucketName", &b.BucketName) + delete(rawMsg, key) + case "insecure": + err = unpopulate(val, "Insecure", &b.Insecure) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &b.LocalAuthRef) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &b.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &b.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &b.URL) + 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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FluxConfiguration. +func (f FluxConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FluxConfiguration. +func (f *FluxConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FluxConfigurationPatch. +func (f FluxConfigurationPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", f.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FluxConfigurationPatch. +func (f *FluxConfigurationPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FluxConfigurationPatchProperties. +func (f FluxConfigurationPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureBlob", f.AzureBlob) + populate(objectMap, "bucket", f.Bucket) + populate(objectMap, "configurationProtectedSettings", f.ConfigurationProtectedSettings) + populate(objectMap, "gitRepository", f.GitRepository) + populate(objectMap, "kustomizations", f.Kustomizations) + populate(objectMap, "ociRepository", f.OciRepository) + populate(objectMap, "sourceKind", f.SourceKind) + populate(objectMap, "suspend", f.Suspend) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FluxConfigurationPatchProperties. +func (f *FluxConfigurationPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureBlob": + err = unpopulate(val, "AzureBlob", &f.AzureBlob) + delete(rawMsg, key) + case "bucket": + err = unpopulate(val, "Bucket", &f.Bucket) + delete(rawMsg, key) + case "configurationProtectedSettings": + err = unpopulate(val, "ConfigurationProtectedSettings", &f.ConfigurationProtectedSettings) + delete(rawMsg, key) + case "gitRepository": + err = unpopulate(val, "GitRepository", &f.GitRepository) + delete(rawMsg, key) + case "kustomizations": + err = unpopulate(val, "Kustomizations", &f.Kustomizations) + delete(rawMsg, key) + case "ociRepository": + err = unpopulate(val, "OciRepository", &f.OciRepository) + delete(rawMsg, key) + case "sourceKind": + err = unpopulate(val, "SourceKind", &f.SourceKind) + delete(rawMsg, key) + case "suspend": + err = unpopulate(val, "Suspend", &f.Suspend) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FluxConfigurationProperties. +func (f FluxConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureBlob", f.AzureBlob) + populate(objectMap, "bucket", f.Bucket) + populate(objectMap, "complianceState", f.ComplianceState) + populate(objectMap, "configurationProtectedSettings", f.ConfigurationProtectedSettings) + populate(objectMap, "errorMessage", f.ErrorMessage) + populate(objectMap, "gitRepository", f.GitRepository) + populate(objectMap, "kustomizations", f.Kustomizations) + populate(objectMap, "namespace", f.Namespace) + populate(objectMap, "ociRepository", f.OciRepository) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "reconciliationWaitDuration", f.ReconciliationWaitDuration) + populate(objectMap, "repositoryPublicKey", f.RepositoryPublicKey) + populate(objectMap, "scope", f.Scope) + populate(objectMap, "sourceKind", f.SourceKind) + populate(objectMap, "sourceSyncedCommitId", f.SourceSyncedCommitID) + populateDateTimeRFC3339(objectMap, "sourceUpdatedAt", f.SourceUpdatedAt) + populateDateTimeRFC3339(objectMap, "statusUpdatedAt", f.StatusUpdatedAt) + populate(objectMap, "statuses", f.Statuses) + populate(objectMap, "suspend", f.Suspend) + populate(objectMap, "waitForReconciliation", f.WaitForReconciliation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FluxConfigurationProperties. +func (f *FluxConfigurationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureBlob": + err = unpopulate(val, "AzureBlob", &f.AzureBlob) + delete(rawMsg, key) + case "bucket": + err = unpopulate(val, "Bucket", &f.Bucket) + delete(rawMsg, key) + case "complianceState": + err = unpopulate(val, "ComplianceState", &f.ComplianceState) + delete(rawMsg, key) + case "configurationProtectedSettings": + err = unpopulate(val, "ConfigurationProtectedSettings", &f.ConfigurationProtectedSettings) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &f.ErrorMessage) + delete(rawMsg, key) + case "gitRepository": + err = unpopulate(val, "GitRepository", &f.GitRepository) + delete(rawMsg, key) + case "kustomizations": + err = unpopulate(val, "Kustomizations", &f.Kustomizations) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &f.Namespace) + delete(rawMsg, key) + case "ociRepository": + err = unpopulate(val, "OciRepository", &f.OciRepository) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "reconciliationWaitDuration": + err = unpopulate(val, "ReconciliationWaitDuration", &f.ReconciliationWaitDuration) + delete(rawMsg, key) + case "repositoryPublicKey": + err = unpopulate(val, "RepositoryPublicKey", &f.RepositoryPublicKey) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &f.Scope) + delete(rawMsg, key) + case "sourceKind": + err = unpopulate(val, "SourceKind", &f.SourceKind) + delete(rawMsg, key) + case "sourceSyncedCommitId": + err = unpopulate(val, "SourceSyncedCommitID", &f.SourceSyncedCommitID) + delete(rawMsg, key) + case "sourceUpdatedAt": + err = unpopulateDateTimeRFC3339(val, "SourceUpdatedAt", &f.SourceUpdatedAt) + delete(rawMsg, key) + case "statusUpdatedAt": + err = unpopulateDateTimeRFC3339(val, "StatusUpdatedAt", &f.StatusUpdatedAt) + delete(rawMsg, key) + case "statuses": + err = unpopulate(val, "Statuses", &f.Statuses) + delete(rawMsg, key) + case "suspend": + err = unpopulate(val, "Suspend", &f.Suspend) + delete(rawMsg, key) + case "waitForReconciliation": + err = unpopulate(val, "WaitForReconciliation", &f.WaitForReconciliation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitRepositoryDefinition. +func (g GitRepositoryDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "httpsCACert", g.HTTPSCACert) + populate(objectMap, "httpsUser", g.HTTPSUser) + populate(objectMap, "localAuthRef", g.LocalAuthRef) + populate(objectMap, "provider", g.Provider) + populate(objectMap, "repositoryRef", g.RepositoryRef) + populate(objectMap, "sshKnownHosts", g.SSHKnownHosts) + populate(objectMap, "syncIntervalInSeconds", g.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", g.TimeoutInSeconds) + populate(objectMap, "url", g.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitRepositoryDefinition. +func (g *GitRepositoryDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "httpsCACert": + err = unpopulate(val, "HTTPSCACert", &g.HTTPSCACert) + delete(rawMsg, key) + case "httpsUser": + err = unpopulate(val, "HTTPSUser", &g.HTTPSUser) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &g.LocalAuthRef) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &g.Provider) + delete(rawMsg, key) + case "repositoryRef": + err = unpopulate(val, "RepositoryRef", &g.RepositoryRef) + delete(rawMsg, key) + case "sshKnownHosts": + err = unpopulate(val, "SSHKnownHosts", &g.SSHKnownHosts) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &g.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &g.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &g.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitRepositoryPatchDefinition. +func (g GitRepositoryPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "httpsCACert", g.HTTPSCACert) + populate(objectMap, "httpsUser", g.HTTPSUser) + populate(objectMap, "localAuthRef", g.LocalAuthRef) + populate(objectMap, "provider", g.Provider) + populate(objectMap, "repositoryRef", g.RepositoryRef) + populate(objectMap, "sshKnownHosts", g.SSHKnownHosts) + populate(objectMap, "syncIntervalInSeconds", g.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", g.TimeoutInSeconds) + populate(objectMap, "url", g.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitRepositoryPatchDefinition. +func (g *GitRepositoryPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "httpsCACert": + err = unpopulate(val, "HTTPSCACert", &g.HTTPSCACert) + delete(rawMsg, key) + case "httpsUser": + err = unpopulate(val, "HTTPSUser", &g.HTTPSUser) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &g.LocalAuthRef) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &g.Provider) + delete(rawMsg, key) + case "repositoryRef": + err = unpopulate(val, "RepositoryRef", &g.RepositoryRef) + delete(rawMsg, key) + case "sshKnownHosts": + err = unpopulate(val, "SSHKnownHosts", &g.SSHKnownHosts) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &g.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &g.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &g.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HelmReleasePropertiesDefinition. +func (h HelmReleasePropertiesDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "failureCount", h.FailureCount) + populate(objectMap, "helmChartRef", h.HelmChartRef) + populate(objectMap, "installFailureCount", h.InstallFailureCount) + populate(objectMap, "lastRevisionApplied", h.LastRevisionApplied) + populate(objectMap, "upgradeFailureCount", h.UpgradeFailureCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HelmReleasePropertiesDefinition. +func (h *HelmReleasePropertiesDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "failureCount": + err = unpopulate(val, "FailureCount", &h.FailureCount) + delete(rawMsg, key) + case "helmChartRef": + err = unpopulate(val, "HelmChartRef", &h.HelmChartRef) + delete(rawMsg, key) + case "installFailureCount": + err = unpopulate(val, "InstallFailureCount", &h.InstallFailureCount) + delete(rawMsg, key) + case "lastRevisionApplied": + err = unpopulate(val, "LastRevisionApplied", &h.LastRevisionApplied) + delete(rawMsg, key) + case "upgradeFailureCount": + err = unpopulate(val, "UpgradeFailureCount", &h.UpgradeFailureCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KustomizationDefinition. +func (k KustomizationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dependsOn", k.DependsOn) + populate(objectMap, "force", k.Force) + populate(objectMap, "name", k.Name) + populate(objectMap, "path", k.Path) + populate(objectMap, "postBuild", k.PostBuild) + populate(objectMap, "prune", k.Prune) + populate(objectMap, "retryIntervalInSeconds", k.RetryIntervalInSeconds) + populate(objectMap, "syncIntervalInSeconds", k.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", k.TimeoutInSeconds) + populate(objectMap, "wait", k.Wait) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KustomizationDefinition. +func (k *KustomizationDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dependsOn": + err = unpopulate(val, "DependsOn", &k.DependsOn) + delete(rawMsg, key) + case "force": + err = unpopulate(val, "Force", &k.Force) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &k.Name) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &k.Path) + delete(rawMsg, key) + case "postBuild": + err = unpopulate(val, "PostBuild", &k.PostBuild) + delete(rawMsg, key) + case "prune": + err = unpopulate(val, "Prune", &k.Prune) + delete(rawMsg, key) + case "retryIntervalInSeconds": + err = unpopulate(val, "RetryIntervalInSeconds", &k.RetryIntervalInSeconds) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &k.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &k.TimeoutInSeconds) + delete(rawMsg, key) + case "wait": + err = unpopulate(val, "Wait", &k.Wait) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KustomizationPatchDefinition. +func (k KustomizationPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dependsOn", k.DependsOn) + populate(objectMap, "force", k.Force) + populate(objectMap, "path", k.Path) + populate(objectMap, "postBuild", k.PostBuild) + populate(objectMap, "prune", k.Prune) + populate(objectMap, "retryIntervalInSeconds", k.RetryIntervalInSeconds) + populate(objectMap, "syncIntervalInSeconds", k.SyncIntervalInSeconds) + populate(objectMap, "timeoutInSeconds", k.TimeoutInSeconds) + populate(objectMap, "wait", k.Wait) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KustomizationPatchDefinition. +func (k *KustomizationPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dependsOn": + err = unpopulate(val, "DependsOn", &k.DependsOn) + delete(rawMsg, key) + case "force": + err = unpopulate(val, "Force", &k.Force) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &k.Path) + delete(rawMsg, key) + case "postBuild": + err = unpopulate(val, "PostBuild", &k.PostBuild) + delete(rawMsg, key) + case "prune": + err = unpopulate(val, "Prune", &k.Prune) + delete(rawMsg, key) + case "retryIntervalInSeconds": + err = unpopulate(val, "RetryIntervalInSeconds", &k.RetryIntervalInSeconds) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &k.SyncIntervalInSeconds) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &k.TimeoutInSeconds) + delete(rawMsg, key) + case "wait": + err = unpopulate(val, "Wait", &k.Wait) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LayerSelectorDefinition. +func (l LayerSelectorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mediaType", l.MediaType) + populate(objectMap, "operation", l.Operation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LayerSelectorDefinition. +func (l *LayerSelectorDefinition) UnmarshalJSON(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 "mediaType": + err = unpopulate(val, "MediaType", &l.MediaType) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &l.Operation) + 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 LayerSelectorPatchDefinition. +func (l LayerSelectorPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mediaType", l.MediaType) + populate(objectMap, "operation", l.Operation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LayerSelectorPatchDefinition. +func (l *LayerSelectorPatchDefinition) UnmarshalJSON(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 "mediaType": + err = unpopulate(val, "MediaType", &l.MediaType) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &l.Operation) + 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 List. +func (l List) 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 List. +func (l *List) UnmarshalJSON(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 ManagedIdentityDefinition. +func (m ManagedIdentityDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", m.ClientID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityDefinition. +func (m *ManagedIdentityDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &m.ClientID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedIdentityPatchDefinition. +func (m ManagedIdentityPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", m.ClientID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityPatchDefinition. +func (m *ManagedIdentityPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &m.ClientID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MatchOidcIdentityDefinition. +func (m MatchOidcIdentityDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "issuer", m.Issuer) + populate(objectMap, "subject", m.Subject) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MatchOidcIdentityDefinition. +func (m *MatchOidcIdentityDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "issuer": + err = unpopulate(val, "Issuer", &m.Issuer) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &m.Subject) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MatchOidcIdentityPatchDefinition. +func (m MatchOidcIdentityPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "issuer", m.Issuer) + populate(objectMap, "subject", m.Subject) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MatchOidcIdentityPatchDefinition. +func (m *MatchOidcIdentityPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "issuer": + err = unpopulate(val, "Issuer", &m.Issuer) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &m.Subject) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OCIRepositoryDefinition. +func (o OCIRepositoryDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "insecure", o.Insecure) + populate(objectMap, "layerSelector", o.LayerSelector) + populate(objectMap, "localAuthRef", o.LocalAuthRef) + populate(objectMap, "repositoryRef", o.RepositoryRef) + populate(objectMap, "serviceAccountName", o.ServiceAccountName) + populate(objectMap, "syncIntervalInSeconds", o.SyncIntervalInSeconds) + populate(objectMap, "tlsConfig", o.TLSConfig) + populate(objectMap, "timeoutInSeconds", o.TimeoutInSeconds) + populate(objectMap, "url", o.URL) + populate(objectMap, "useWorkloadIdentity", o.UseWorkloadIdentity) + populate(objectMap, "verify", o.Verify) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OCIRepositoryDefinition. +func (o *OCIRepositoryDefinition) UnmarshalJSON(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 "insecure": + err = unpopulate(val, "Insecure", &o.Insecure) + delete(rawMsg, key) + case "layerSelector": + err = unpopulate(val, "LayerSelector", &o.LayerSelector) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &o.LocalAuthRef) + delete(rawMsg, key) + case "repositoryRef": + err = unpopulate(val, "RepositoryRef", &o.RepositoryRef) + delete(rawMsg, key) + case "serviceAccountName": + err = unpopulate(val, "ServiceAccountName", &o.ServiceAccountName) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &o.SyncIntervalInSeconds) + delete(rawMsg, key) + case "tlsConfig": + err = unpopulate(val, "TLSConfig", &o.TLSConfig) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &o.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &o.URL) + delete(rawMsg, key) + case "useWorkloadIdentity": + err = unpopulate(val, "UseWorkloadIdentity", &o.UseWorkloadIdentity) + delete(rawMsg, key) + case "verify": + err = unpopulate(val, "Verify", &o.Verify) + 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 OCIRepositoryPatchDefinition. +func (o OCIRepositoryPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "insecure", o.Insecure) + populate(objectMap, "layerSelector", o.LayerSelector) + populate(objectMap, "localAuthRef", o.LocalAuthRef) + populate(objectMap, "repositoryRef", o.RepositoryRef) + populate(objectMap, "serviceAccountName", o.ServiceAccountName) + populate(objectMap, "syncIntervalInSeconds", o.SyncIntervalInSeconds) + populate(objectMap, "tlsConfig", o.TLSConfig) + populate(objectMap, "timeoutInSeconds", o.TimeoutInSeconds) + populate(objectMap, "url", o.URL) + populate(objectMap, "useWorkloadIdentity", o.UseWorkloadIdentity) + populate(objectMap, "verify", o.Verify) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OCIRepositoryPatchDefinition. +func (o *OCIRepositoryPatchDefinition) UnmarshalJSON(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 "insecure": + err = unpopulate(val, "Insecure", &o.Insecure) + delete(rawMsg, key) + case "layerSelector": + err = unpopulate(val, "LayerSelector", &o.LayerSelector) + delete(rawMsg, key) + case "localAuthRef": + err = unpopulate(val, "LocalAuthRef", &o.LocalAuthRef) + delete(rawMsg, key) + case "repositoryRef": + err = unpopulate(val, "RepositoryRef", &o.RepositoryRef) + delete(rawMsg, key) + case "serviceAccountName": + err = unpopulate(val, "ServiceAccountName", &o.ServiceAccountName) + delete(rawMsg, key) + case "syncIntervalInSeconds": + err = unpopulate(val, "SyncIntervalInSeconds", &o.SyncIntervalInSeconds) + delete(rawMsg, key) + case "tlsConfig": + err = unpopulate(val, "TLSConfig", &o.TLSConfig) + delete(rawMsg, key) + case "timeoutInSeconds": + err = unpopulate(val, "TimeoutInSeconds", &o.TimeoutInSeconds) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &o.URL) + delete(rawMsg, key) + case "useWorkloadIdentity": + err = unpopulate(val, "UseWorkloadIdentity", &o.UseWorkloadIdentity) + delete(rawMsg, key) + case "verify": + err = unpopulate(val, "Verify", &o.Verify) + 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 OCIRepositoryRefDefinition. +func (o OCIRepositoryRefDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", o.Digest) + populate(objectMap, "semver", o.Semver) + populate(objectMap, "tag", o.Tag) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OCIRepositoryRefDefinition. +func (o *OCIRepositoryRefDefinition) UnmarshalJSON(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 "digest": + err = unpopulate(val, "Digest", &o.Digest) + delete(rawMsg, key) + case "semver": + err = unpopulate(val, "Semver", &o.Semver) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &o.Tag) + 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 OCIRepositoryRefPatchDefinition. +func (o OCIRepositoryRefPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", o.Digest) + populate(objectMap, "semver", o.Semver) + populate(objectMap, "tag", o.Tag) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OCIRepositoryRefPatchDefinition. +func (o *OCIRepositoryRefPatchDefinition) UnmarshalJSON(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 "digest": + err = unpopulate(val, "Digest", &o.Digest) + delete(rawMsg, key) + case "semver": + err = unpopulate(val, "Semver", &o.Semver) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &o.Tag) + 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 ObjectReferenceDefinition. +func (o ObjectReferenceDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", o.Name) + populate(objectMap, "namespace", o.Namespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectReferenceDefinition. +func (o *ObjectReferenceDefinition) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &o.Namespace) + 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 ObjectStatusConditionDefinition. +func (o ObjectStatusConditionDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "lastTransitionTime", o.LastTransitionTime) + populate(objectMap, "message", o.Message) + populate(objectMap, "reason", o.Reason) + populate(objectMap, "status", o.Status) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectStatusConditionDefinition. +func (o *ObjectStatusConditionDefinition) UnmarshalJSON(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 "lastTransitionTime": + err = unpopulateDateTimeRFC3339(val, "LastTransitionTime", &o.LastTransitionTime) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &o.Message) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &o.Reason) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 ObjectStatusDefinition. +func (o ObjectStatusDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appliedBy", o.AppliedBy) + populate(objectMap, "complianceState", o.ComplianceState) + populate(objectMap, "helmReleaseProperties", o.HelmReleaseProperties) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "name", o.Name) + populate(objectMap, "namespace", o.Namespace) + populate(objectMap, "statusConditions", o.StatusConditions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectStatusDefinition. +func (o *ObjectStatusDefinition) UnmarshalJSON(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 "appliedBy": + err = unpopulate(val, "AppliedBy", &o.AppliedBy) + delete(rawMsg, key) + case "complianceState": + err = unpopulate(val, "ComplianceState", &o.ComplianceState) + delete(rawMsg, key) + case "helmReleaseProperties": + err = unpopulate(val, "HelmReleaseProperties", &o.HelmReleaseProperties) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &o.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &o.Namespace) + delete(rawMsg, key) + case "statusConditions": + err = unpopulate(val, "StatusConditions", &o.StatusConditions) + 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 OperationStatusResult. +func (o OperationStatusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusResult. +func (o *OperationStatusResult) UnmarshalJSON(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 "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + 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 PostBuildDefinition. +func (p PostBuildDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "substitute", p.Substitute) + populate(objectMap, "substituteFrom", p.SubstituteFrom) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PostBuildDefinition. +func (p *PostBuildDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "substitute": + err = unpopulate(val, "Substitute", &p.Substitute) + delete(rawMsg, key) + case "substituteFrom": + err = unpopulate(val, "SubstituteFrom", &p.SubstituteFrom) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PostBuildPatchDefinition. +func (p PostBuildPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "substitute", p.Substitute) + populate(objectMap, "substituteFrom", p.SubstituteFrom) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PostBuildPatchDefinition. +func (p *PostBuildPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "substitute": + err = unpopulate(val, "Substitute", &p.Substitute) + delete(rawMsg, key) + case "substituteFrom": + err = unpopulate(val, "SubstituteFrom", &p.SubstituteFrom) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RepositoryRefDefinition. +func (r RepositoryRefDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branch", r.Branch) + populate(objectMap, "commit", r.Commit) + populate(objectMap, "semver", r.Semver) + populate(objectMap, "tag", r.Tag) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RepositoryRefDefinition. +func (r *RepositoryRefDefinition) UnmarshalJSON(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 "branch": + err = unpopulate(val, "Branch", &r.Branch) + delete(rawMsg, key) + case "commit": + err = unpopulate(val, "Commit", &r.Commit) + delete(rawMsg, key) + case "semver": + err = unpopulate(val, "Semver", &r.Semver) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &r.Tag) + 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 ServicePrincipalDefinition. +func (s ServicePrincipalDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientCertificate", s.ClientCertificate) + populate(objectMap, "clientCertificatePassword", s.ClientCertificatePassword) + populate(objectMap, "clientCertificateSendChain", s.ClientCertificateSendChain) + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "clientSecret", s.ClientSecret) + populate(objectMap, "tenantId", s.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalDefinition. +func (s *ServicePrincipalDefinition) UnmarshalJSON(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 "clientCertificate": + err = unpopulate(val, "ClientCertificate", &s.ClientCertificate) + delete(rawMsg, key) + case "clientCertificatePassword": + err = unpopulate(val, "ClientCertificatePassword", &s.ClientCertificatePassword) + delete(rawMsg, key) + case "clientCertificateSendChain": + err = unpopulate(val, "ClientCertificateSendChain", &s.ClientCertificateSendChain) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &s.ClientID) + delete(rawMsg, key) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &s.ClientSecret) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &s.TenantID) + 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 ServicePrincipalPatchDefinition. +func (s ServicePrincipalPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientCertificate", s.ClientCertificate) + populate(objectMap, "clientCertificatePassword", s.ClientCertificatePassword) + populate(objectMap, "clientCertificateSendChain", s.ClientCertificateSendChain) + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "clientSecret", s.ClientSecret) + populate(objectMap, "tenantId", s.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalPatchDefinition. +func (s *ServicePrincipalPatchDefinition) UnmarshalJSON(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 "clientCertificate": + err = unpopulate(val, "ClientCertificate", &s.ClientCertificate) + delete(rawMsg, key) + case "clientCertificatePassword": + err = unpopulate(val, "ClientCertificatePassword", &s.ClientCertificatePassword) + delete(rawMsg, key) + case "clientCertificateSendChain": + err = unpopulate(val, "ClientCertificateSendChain", &s.ClientCertificateSendChain) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &s.ClientID) + delete(rawMsg, key) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &s.ClientSecret) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &s.TenantID) + 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 SubstituteFromDefinition. +func (s SubstituteFromDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "name", s.Name) + populate(objectMap, "optional", s.Optional) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubstituteFromDefinition. +func (s *SubstituteFromDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "optional": + err = unpopulate(val, "Optional", &s.Optional) + 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 SubstituteFromPatchDefinition. +func (s SubstituteFromPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "name", s.Name) + populate(objectMap, "optional", s.Optional) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubstituteFromPatchDefinition. +func (s *SubstituteFromPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "optional": + err = unpopulate(val, "Optional", &s.Optional) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TLSConfigDefinition. +func (t TLSConfigDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "caCertificate", t.CaCertificate) + populate(objectMap, "clientCertificate", t.ClientCertificate) + populate(objectMap, "privateKey", t.PrivateKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TLSConfigDefinition. +func (t *TLSConfigDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "caCertificate": + err = unpopulate(val, "CaCertificate", &t.CaCertificate) + delete(rawMsg, key) + case "clientCertificate": + err = unpopulate(val, "ClientCertificate", &t.ClientCertificate) + delete(rawMsg, key) + case "privateKey": + err = unpopulate(val, "PrivateKey", &t.PrivateKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TLSConfigPatchDefinition. +func (t TLSConfigPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "caCertificate", t.CaCertificate) + populate(objectMap, "clientCertificate", t.ClientCertificate) + populate(objectMap, "privateKey", t.PrivateKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TLSConfigPatchDefinition. +func (t *TLSConfigPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "caCertificate": + err = unpopulate(val, "CaCertificate", &t.CaCertificate) + delete(rawMsg, key) + case "clientCertificate": + err = unpopulate(val, "ClientCertificate", &t.ClientCertificate) + delete(rawMsg, key) + case "privateKey": + err = unpopulate(val, "PrivateKey", &t.PrivateKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VerifyDefinition. +func (v VerifyDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "matchOidcIdentity", v.MatchOidcIdentity) + populate(objectMap, "provider", v.Provider) + populate(objectMap, "verificationConfig", v.VerificationConfig) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VerifyDefinition. +func (v *VerifyDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "matchOidcIdentity": + err = unpopulate(val, "MatchOidcIdentity", &v.MatchOidcIdentity) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &v.Provider) + delete(rawMsg, key) + case "verificationConfig": + err = unpopulate(val, "VerificationConfig", &v.VerificationConfig) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VerifyPatchDefinition. +func (v VerifyPatchDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "matchOidcIdentity", v.MatchOidcIdentity) + populate(objectMap, "provider", v.Provider) + populate(objectMap, "verificationConfig", v.VerificationConfig) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VerifyPatchDefinition. +func (v *VerifyPatchDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "matchOidcIdentity": + err = unpopulate(val, "MatchOidcIdentity", &v.MatchOidcIdentity) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &v.Provider) + delete(rawMsg, key) + case "verificationConfig": + err = unpopulate(val, "VerificationConfig", &v.VerificationConfig) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/options.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/options.go new file mode 100644 index 000000000000..6ebe55c605e8 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/options.go @@ -0,0 +1,43 @@ +// 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 armfluxconfigurations + +// ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +type ClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +type ClientBeginDeleteOptions struct { + // Delete the extension resource in Azure - not the normal asynchronous delete. + ForceDelete *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +type ClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListOptions contains the optional parameters for the Client.NewListPager method. +type ClientListOptions struct { + // placeholder for future optional parameters +} + +// FluxConfigOperationStatusClientGetOptions contains the optional parameters for the FluxConfigOperationStatusClient.Get +// method. +type FluxConfigOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/responses.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/responses.go new file mode 100644 index 000000000000..a88881ec42f7 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/responses.go @@ -0,0 +1,42 @@ +// 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 armfluxconfigurations + +// ClientCreateOrUpdateResponse contains the response from method Client.BeginCreateOrUpdate. +type ClientCreateOrUpdateResponse struct { + // The Flux Configuration object returned in Get & Put response. + FluxConfiguration +} + +// ClientDeleteResponse contains the response from method Client.BeginDelete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // The Flux Configuration object returned in Get & Put response. + FluxConfiguration +} + +// ClientListResponse contains the response from method Client.NewListPager. +type ClientListResponse struct { + // Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get + // the next set of results. + List +} + +// ClientUpdateResponse contains the response from method Client.BeginUpdate. +type ClientUpdateResponse struct { + // The Flux Configuration object returned in Get & Put response. + FluxConfiguration +} + +// FluxConfigOperationStatusClientGetResponse contains the response from method FluxConfigOperationStatusClient.Get. +type FluxConfigOperationStatusClientGetResponse struct { + // The current status of an async operation. + OperationStatusResult +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/time_rfc3339.go b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/time_rfc3339.go new file mode 100644 index 000000000000..4e23949786ba --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/time_rfc3339.go @@ -0,0 +1,110 @@ +// 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 armfluxconfigurations + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/CHANGELOG.md b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/CHANGELOG.md new file mode 100644 index 000000000000..a311a04cfba5 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-13) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes` 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/kubernetesconfiguration/armprivatelinkscopes/LICENSE.txt b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/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/kubernetesconfiguration/armprivatelinkscopes/README.md b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/README.md new file mode 100644 index 000000000000..21ad8f66e615 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/README.md @@ -0,0 +1,90 @@ +# Azure Kubernetesconfiguration Module for Go + +The `armprivatelinkscopes` module provides operations for working with Azure Kubernetesconfiguration. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes) + +# 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 Kubernetesconfiguration module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetesconfiguration. 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 Kubernetesconfiguration 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 := armprivatelinkscopes.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 := armprivatelinkscopes.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.NewClient() +``` + +## 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 `Kubernetesconfiguration` 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/kubernetesconfiguration/armprivatelinkscopes/autorest.md b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/autorest.md new file mode 100644 index 000000000000..3c6038cd8fd3 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/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/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/privateLinkScopes/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/privateLinkScopes/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/build.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/build.go new file mode 100644 index 000000000000..88282d8bb277 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/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/kubernetesconfiguration/armprivatelinkscopes + +package armprivatelinkscopes diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/ci.yml b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/ci.yml new file mode 100644 index 000000000000..ea4a5163661b --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/ci.yml @@ -0,0 +1,27 @@ +# 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/kubernetesconfiguration/armprivatelinkscopes/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/kubernetesconfiguration/armprivatelinkscopes' diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client.go new file mode 100644 index 000000000000..f41dcc115280 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client.go @@ -0,0 +1,410 @@ +// 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 armprivatelinkscopes + +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" +) + +// Client contains the methods for the PrivateLinkScopes group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey +// nor AppId in the Put operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - parameters - Properties that need to be specified to create or update a Azure Arc for Servers and Clusters PrivateLinkScope. +// - options - ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. +func (client *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, parameters KubernetesConfigurationPrivateLinkScope, options *ClientCreateOrUpdateOptions) (ClientCreateOrUpdateResponse, error) { + var err error + const operationName = "Client.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, resourceGroupName, scopeName, parameters, options) + if err != nil { + return ClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, parameters KubernetesConfigurationPrivateLinkScope, _ *ClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *Client) createOrUpdateHandleResponse(resp *http.Response) (ClientCreateOrUpdateResponse, error) { + result := ClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KubernetesConfigurationPrivateLinkScope); err != nil { + return ClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a Azure Arc PrivateLinkScope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. +func (client *Client) Delete(ctx context.Context, resourceGroupName string, scopeName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) { + var err error + const operationName = "Client.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, resourceGroupName, scopeName, options) + if err != nil { + return ClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteResponse{}, err + } + return ClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, _ *ClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns a Azure Arc PrivateLinkScope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, scopeName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KubernetesConfigurationPrivateLinkScope); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of all Azure Arc PrivateLinkScopes within a subscription. +// +// Generated from API version 2024-11-01-preview +// - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. +func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[ClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ + More: func(page ClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListResponse) (ClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.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 ClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *Client) listCreateRequest(ctx context.Context, _ *ClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *Client) listHandleResponse(resp *http.Response) (ClientListResponse, error) { + result := ClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KubernetesConfigurationPrivateLinkScopeListResult); err != nil { + return ClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of Azure Arc PrivateLinkScopes within a resource group. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager +// method. +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KubernetesConfigurationPrivateLinkScopeListResult); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// UpdateTags - Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - privateLinkScopeTags - Updated tag information to set into the PrivateLinkScope instance. +// - options - ClientUpdateTagsOptions contains the optional parameters for the Client.UpdateTags method. +func (client *Client) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource, options *ClientUpdateTagsOptions) (ClientUpdateTagsResponse, error) { + var err error + const operationName = "Client.UpdateTags" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, scopeName, privateLinkScopeTags, options) + if err != nil { + return ClientUpdateTagsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateTagsResponse{}, err + } + resp, err := client.updateTagsHandleResponse(httpResp) + return resp, err +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *Client) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource, _ *ClientUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, privateLinkScopeTags); err != nil { + return nil, err + } + return req, nil +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *Client) updateTagsHandleResponse(resp *http.Response) (ClientUpdateTagsResponse, error) { + result := ClientUpdateTagsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KubernetesConfigurationPrivateLinkScope); err != nil { + return ClientUpdateTagsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client_factory.go new file mode 100644 index 000000000000..f181b98a2e22 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/client_factory.go @@ -0,0 +1,58 @@ +// 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 armprivatelinkscopes + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + return &PrivateLinkResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/constants.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/constants.go new file mode 100644 index 000000000000..16778e31e4f9 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/constants.go @@ -0,0 +1,114 @@ +// 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 armprivatelinkscopes + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// PrivateEndpointConnectionProvisioningState - The current provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + } +} + +// PrivateEndpointServiceConnectionStatus - The private endpoint connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns the possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{ + PrivateEndpointServiceConnectionStatusApproved, + PrivateEndpointServiceConnectionStatusPending, + PrivateEndpointServiceConnectionStatusRejected, + } +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// PublicNetworkAccessType - The network access policy to determine if Azure Arc agents can use public Azure Arc service endpoints. +// Defaults to disabled (access to Azure Arc services only via private link). +type PublicNetworkAccessType string + +const ( + // PublicNetworkAccessTypeDisabled - Does not allow Azure Arc agents to communicate with Azure Arc services over public (internet) + // endpoints. The agents must use the private link. + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + // PublicNetworkAccessTypeEnabled - Allows Azure Arc agents to communicate with Azure Arc services over both public (internet) + // and private endpoints. + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +// PossiblePublicNetworkAccessTypeValues returns the possible values for the PublicNetworkAccessType const type. +func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { + return []PublicNetworkAccessType{ + PublicNetworkAccessTypeDisabled, + PublicNetworkAccessTypeEnabled, + } +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/internal.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/internal.go new file mode 100644 index 000000000000..4b65adc76adb --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/internal.go @@ -0,0 +1,66 @@ +// 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 result struct { + resp *http.Response + err error +} + +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/kubernetesconfiguration/armprivatelinkscopes/fake/privateendpointconnections_server.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..b2546df82460 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/privateendpointconnections_server.go @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes" + "net/http" + "net/url" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armprivatelinkscopes.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // BeginCreateOrUpdate is the fake for method PrivateEndpointConnectionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, properties armprivatelinkscopes.PrivateEndpointConnection, options *armprivatelinkscopes.PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armprivatelinkscopes.PrivateEndpointConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method PrivateEndpointConnectionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *armprivatelinkscopes.PrivateEndpointConnectionsClientDeleteOptions) (resp azfake.Responder[armprivatelinkscopes.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *armprivatelinkscopes.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armprivatelinkscopes.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // ListByPrivateLinkScope is the fake for method PrivateEndpointConnectionsClient.ListByPrivateLinkScope + // HTTP status codes to indicate success: http.StatusOK + ListByPrivateLinkScope func(ctx context.Context, resourceGroupName string, scopeName string, options *armprivatelinkscopes.PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions) (resp azfake.Responder[armprivatelinkscopes.PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armprivatelinkscopes.PrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armprivatelinkscopes.PrivateEndpointConnectionsClientCreateOrUpdateResponse]](), + } +} + +// PrivateEndpointConnectionsServerTransport connects instances of armprivatelinkscopes.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armprivatelinkscopes.PrivateEndpointConnectionsClientCreateOrUpdateResponse]] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if privateEndpointConnectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateEndpointConnectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateEndpointConnectionsClient.BeginCreateOrUpdate": + res.resp, res.err = p.dispatchBeginCreateOrUpdate(req) + case "PrivateEndpointConnectionsClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PrivateEndpointConnectionsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.ListByPrivateLinkScope": + res.resp, res.err = p.dispatchListByPrivateLinkScope(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := p.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armprivatelinkscopes.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + p.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + p.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, 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 (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchListByPrivateLinkScope(req *http.Request) (*http.Response, error) { + if p.srv.ListByPrivateLinkScope == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByPrivateLinkScope not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByPrivateLinkScope(req.Context(), resourceGroupNameParam, scopeNameParam, 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).PrivateEndpointConnectionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to PrivateEndpointConnectionsServerTransport +var privateEndpointConnectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/privatelinkresources_server.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..c26c02363744 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/privatelinkresources_server.go @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armprivatelinkscopes.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // Get is the fake for method PrivateLinkResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *armprivatelinkscopes.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armprivatelinkscopes.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // ListByPrivateLinkScope is the fake for method PrivateLinkResourcesClient.ListByPrivateLinkScope + // HTTP status codes to indicate success: http.StatusOK + ListByPrivateLinkScope func(ctx context.Context, resourceGroupName string, scopeName string, options *armprivatelinkscopes.PrivateLinkResourcesClientListByPrivateLinkScopeOptions) (resp azfake.Responder[armprivatelinkscopes.PrivateLinkResourcesClientListByPrivateLinkScopeResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armprivatelinkscopes.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{srv: srv} +} + +// PrivateLinkResourcesServerTransport connects instances of armprivatelinkscopes.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PrivateLinkResourcesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if privateLinkResourcesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateLinkResourcesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateLinkResourcesClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateLinkResourcesClient.ListByPrivateLinkScope": + res.resp, res.err = p.dispatchListByPrivateLinkScope(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + groupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, groupNameParam, 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).PrivateLinkResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchListByPrivateLinkScope(req *http.Request) (*http.Response, error) { + if p.srv.ListByPrivateLinkScope == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByPrivateLinkScope not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByPrivateLinkScope(req.Context(), resourceGroupNameParam, scopeNameParam, 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).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to PrivateLinkResourcesServerTransport +var privateLinkResourcesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server.go new file mode 100644 index 000000000000..01912e910f0d --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server.go @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) 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/kubernetesconfiguration/armprivatelinkscopes" + "net/http" + "net/url" + "regexp" +) + +// Server is a fake server for instances of the armprivatelinkscopes.Client type. +type Server struct { + // CreateOrUpdate is the fake for method Client.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, scopeName string, parameters armprivatelinkscopes.KubernetesConfigurationPrivateLinkScope, options *armprivatelinkscopes.ClientCreateOrUpdateOptions) (resp azfake.Responder[armprivatelinkscopes.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method Client.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, scopeName string, options *armprivatelinkscopes.ClientDeleteOptions) (resp azfake.Responder[armprivatelinkscopes.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, options *armprivatelinkscopes.ClientGetOptions) (resp azfake.Responder[armprivatelinkscopes.ClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method Client.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armprivatelinkscopes.ClientListOptions) (resp azfake.PagerResponder[armprivatelinkscopes.ClientListResponse]) + + // NewListByResourceGroupPager is the fake for method Client.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armprivatelinkscopes.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[armprivatelinkscopes.ClientListByResourceGroupResponse]) + + // UpdateTags is the fake for method Client.UpdateTags + // HTTP status codes to indicate success: http.StatusOK + UpdateTags func(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags armprivatelinkscopes.TagsResource, options *armprivatelinkscopes.ClientUpdateTagsOptions) (resp azfake.Responder[armprivatelinkscopes.ClientUpdateTagsResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armprivatelinkscopes.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armprivatelinkscopes.ClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armprivatelinkscopes.ClientListByResourceGroupResponse]](), + } +} + +// ServerTransport connects instances of armprivatelinkscopes.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + newListPager *tracker[azfake.PagerResponder[armprivatelinkscopes.ClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armprivatelinkscopes.ClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "Client.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.UpdateTags": + res.resp, res.err = s.dispatchUpdateTags(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armprivatelinkscopes.KubernetesConfigurationPrivateLinkScope](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, scopeNameParam, 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).KubernetesConfigurationPrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, scopeNameParam, 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 *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, 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).KubernetesConfigurationPrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) 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 = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListPager(nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armprivatelinkscopes.ClientListResponse, 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 *ServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armprivatelinkscopes.ClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { + if s.srv.UpdateTags == nil { + return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armprivatelinkscopes.TagsResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.UpdateTags(req.Context(), resourceGroupNameParam, scopeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).KubernetesConfigurationPrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server_factory.go new file mode 100644 index 000000000000..2db03d2a855c --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/fake/server_factory.go @@ -0,0 +1,91 @@ +// 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 armprivatelinkscopes.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // PrivateEndpointConnectionsServer contains the fakes for client PrivateEndpointConnectionsClient + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + + // PrivateLinkResourcesServer contains the fakes for client PrivateLinkResourcesClient + PrivateLinkResourcesServer PrivateLinkResourcesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armprivatelinkscopes.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 armprivatelinkscopes.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "PrivateEndpointConnectionsClient": + initServer(s, &s.trPrivateEndpointConnectionsServer, func() *PrivateEndpointConnectionsServerTransport { + return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) + }) + resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.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/kubernetesconfiguration/armprivatelinkscopes/go.mod b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/go.mod new file mode 100644 index 000000000000..923cb922ddaf --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/go.sum b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models.go new file mode 100644 index 000000000000..2f84823ef445 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models.go @@ -0,0 +1,181 @@ +// 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 armprivatelinkscopes + +import "time" + +// KubernetesConfigurationPrivateLinkScope - An Azure Arc PrivateLinkScope definition. +type KubernetesConfigurationPrivateLinkScope struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Properties that define a Azure Arc PrivateLinkScope resource. + Properties *KubernetesConfigurationPrivateLinkScopeProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// KubernetesConfigurationPrivateLinkScopeListResult - Describes the list of Azure Arc PrivateLinkScope resources. +type KubernetesConfigurationPrivateLinkScopeListResult struct { + // REQUIRED; List of Azure Arc PrivateLinkScope definitions. + Value []*KubernetesConfigurationPrivateLinkScope + + // The URI to get the next set of Azure Arc PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the + // result set. + NextLink *string +} + +// KubernetesConfigurationPrivateLinkScopeProperties - Properties that define a Azure Arc PrivateLinkScope resource. +type KubernetesConfigurationPrivateLinkScopeProperties struct { + // REQUIRED; Managed Cluster ARM ID for the private link scope (Required) + ClusterResourceID *string + + // Indicates whether machines associated with the private link scope can also use public Azure Arc service endpoints. + PublicNetworkAccess *PublicNetworkAccessType + + // READ-ONLY; The collection of associated Private Endpoint Connections. + PrivateEndpointConnections []*PrivateEndpointConnection + + // READ-ONLY; The Guid id of the private link scope. + PrivateLinkScopeID *string + + // READ-ONLY; Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it + // is defined. Users cannot change this value but are able to read from it. Values will include + // Provisioning ,Succeeded, Canceled and Failed. + ProvisioningState *ProvisioningState +} + +// PrivateEndpoint - The Private Endpoint resource. +type PrivateEndpoint struct { + // READ-ONLY; The ARM identifier for Private Endpoint + ID *string +} + +// PrivateEndpointConnection - The Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + // Resource properties. + Properties *PrivateEndpointConnectionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account +type PrivateEndpointConnectionListResult struct { + // Array of private endpoint connections + Value []*PrivateEndpointConnection +} + +// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // REQUIRED; A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState + + // The resource of private end point. + PrivateEndpoint *PrivateEndpoint + + // READ-ONLY; The provisioning state of the private endpoint connection resource. + ProvisioningState *PrivateEndpointConnectionProvisioningState +} + +// PrivateLinkResource - A private link resource +type PrivateLinkResource struct { + // Resource properties. + Properties *PrivateLinkResourceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PrivateLinkResourceListResult - A list of private link resources +type PrivateLinkResourceListResult struct { + // Array of private link resources + Value []*PrivateLinkResource +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // The private link resource Private link DNS zone name. + RequiredZoneNames []*string + + // READ-ONLY; The private link resource group id. + GroupID *string + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string +} + +// PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer +// and provider. +type PrivateLinkServiceConnectionState struct { + // A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string + + // The reason for approval/rejection of the connection. + Description *string + + // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + Status *PrivateEndpointServiceConnectionStatus +} + +// 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 +} + +// TagsResource - A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope +// instance. +type TagsResource struct { + // Resource tags + Tags map[string]*string +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models_serde.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models_serde.go new file mode 100644 index 000000000000..f02ccca57568 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/models_serde.go @@ -0,0 +1,504 @@ +// 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 armprivatelinkscopes + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type KubernetesConfigurationPrivateLinkScope. +func (k KubernetesConfigurationPrivateLinkScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", k.ID) + populate(objectMap, "location", k.Location) + populate(objectMap, "name", k.Name) + populate(objectMap, "properties", k.Properties) + populate(objectMap, "systemData", k.SystemData) + populate(objectMap, "tags", k.Tags) + populate(objectMap, "type", k.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesConfigurationPrivateLinkScope. +func (k *KubernetesConfigurationPrivateLinkScope) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &k.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &k.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &k.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &k.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &k.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &k.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesConfigurationPrivateLinkScopeListResult. +func (k KubernetesConfigurationPrivateLinkScopeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", k.NextLink) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesConfigurationPrivateLinkScopeListResult. +func (k *KubernetesConfigurationPrivateLinkScopeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &k.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesConfigurationPrivateLinkScopeProperties. +func (k KubernetesConfigurationPrivateLinkScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterResourceId", k.ClusterResourceID) + populate(objectMap, "privateEndpointConnections", k.PrivateEndpointConnections) + populate(objectMap, "privateLinkScopeId", k.PrivateLinkScopeID) + populate(objectMap, "provisioningState", k.ProvisioningState) + populate(objectMap, "publicNetworkAccess", k.PublicNetworkAccess) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesConfigurationPrivateLinkScopeProperties. +func (k *KubernetesConfigurationPrivateLinkScopeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterResourceId": + err = unpopulate(val, "ClusterResourceID", &k.ClusterResourceID) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &k.PrivateEndpointConnections) + delete(rawMsg, key) + case "privateLinkScopeId": + err = unpopulate(val, "PrivateLinkScopeID", &k.PrivateLinkScopeID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &k.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &k.PublicNetworkAccess) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpoint. +func (p PrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpoint. +func (p *PrivateEndpoint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnection. +func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionListResult. +func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. +func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. +func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. +func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. +func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagsResource. +func (t TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagsResource. +func (t *TagsResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, 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/kubernetesconfiguration/armprivatelinkscopes/options.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/options.go new file mode 100644 index 000000000000..ffb0736413f2 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/options.go @@ -0,0 +1,72 @@ +// 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 armprivatelinkscopes + +// ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. +type ClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClientDeleteOptions contains the optional parameters for the Client.Delete method. +type ClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager method. +type ClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListOptions contains the optional parameters for the Client.NewListPager method. +type ClientListOptions struct { + // placeholder for future optional parameters +} + +// ClientUpdateTagsOptions contains the optional parameters for the Client.UpdateTags method. +type ClientUpdateTagsOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate +// method. +type PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete +// method. +type PrivateEndpointConnectionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. +type PrivateEndpointConnectionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByPrivateLinkScope +// method. +type PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get method. +type PrivateLinkResourcesClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByPrivateLinkScope +// method. +type PrivateLinkResourcesClientListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privateendpointconnections_client.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privateendpointconnections_client.go new file mode 100644 index 000000000000..6a7ef2162465 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privateendpointconnections_client.go @@ -0,0 +1,321 @@ +// 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 armprivatelinkscopes + +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" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PrivateEndpointConnectionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - properties - The private endpoint connection properties. +// - options - PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate +// method. +func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PrivateEndpointConnectionsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, _ *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes a private endpoint connection with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete +// method. +func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (PrivateEndpointConnectionsClientDeleteResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, resourceGroupName, scopeName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientDeleteResponse{}, err + } + return PrivateEndpointConnectionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a private endpoint connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Response) (PrivateEndpointConnectionsClientGetResponse, error) { + result := PrivateEndpointConnectionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsClientGetResponse{}, err + } + return result, nil +} + +// ListByPrivateLinkScope - Gets all private endpoint connections on a private link scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - options - PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByPrivateLinkScope +// method. +func (client *PrivateEndpointConnectionsClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions) (PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.ListByPrivateLinkScope" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + if err != nil { + return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err + } + resp, err := client.listByPrivateLinkScopeHandleResponse(httpResp) + return resp, err +} + +// listByPrivateLinkScopeCreateRequest creates the ListByPrivateLinkScope request. +func (client *PrivateEndpointConnectionsClient) listByPrivateLinkScopeCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, _ *PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPrivateLinkScopeHandleResponse handles the ListByPrivateLinkScope response. +func (client *PrivateEndpointConnectionsClient) listByPrivateLinkScopeHandleResponse(resp *http.Response) (PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse, error) { + result := PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnectionListResult); err != nil { + return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privatelinkresources_client.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privatelinkresources_client.go new file mode 100644 index 000000000000..d2576cce1afd --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/privatelinkresources_client.go @@ -0,0 +1,176 @@ +// 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 armprivatelinkscopes + +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" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PrivateLinkResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - groupName - The name of the private link resource. +// - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get +// method. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, groupName, options) + if err != nil { + return PrivateLinkResourcesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourcesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, groupName string, _ *PrivateLinkResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if groupName == "" { + return nil, errors.New("parameter groupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) (PrivateLinkResourcesClientGetResponse, error) { + result := PrivateLinkResourcesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResource); err != nil { + return PrivateLinkResourcesClientGetResponse{}, err + } + return result, nil +} + +// ListByPrivateLinkScope - Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scopeName - The name of the Azure Arc PrivateLinkScope resource. +// - options - PrivateLinkResourcesClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByPrivateLinkScope +// method. +func (client *PrivateLinkResourcesClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkResourcesClientListByPrivateLinkScopeOptions) (PrivateLinkResourcesClientListByPrivateLinkScopeResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.ListByPrivateLinkScope" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + if err != nil { + return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err + } + resp, err := client.listByPrivateLinkScopeHandleResponse(httpResp) + return resp, err +} + +// listByPrivateLinkScopeCreateRequest creates the ListByPrivateLinkScope request. +func (client *PrivateLinkResourcesClient) listByPrivateLinkScopeCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, _ *PrivateLinkResourcesClientListByPrivateLinkScopeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPrivateLinkScopeHandleResponse handles the ListByPrivateLinkScope response. +func (client *PrivateLinkResourcesClient) listByPrivateLinkScopeHandleResponse(resp *http.Response) (PrivateLinkResourcesClientListByPrivateLinkScopeResponse, error) { + result := PrivateLinkResourcesClientListByPrivateLinkScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourceListResult); err != nil { + return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/responses.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/responses.go new file mode 100644 index 000000000000..00448235dcdb --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/responses.go @@ -0,0 +1,76 @@ +// 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 armprivatelinkscopes + +// ClientCreateOrUpdateResponse contains the response from method Client.CreateOrUpdate. +type ClientCreateOrUpdateResponse struct { + // An Azure Arc PrivateLinkScope definition. + KubernetesConfigurationPrivateLinkScope +} + +// ClientDeleteResponse contains the response from method Client.Delete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // An Azure Arc PrivateLinkScope definition. + KubernetesConfigurationPrivateLinkScope +} + +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. +type ClientListByResourceGroupResponse struct { + // Describes the list of Azure Arc PrivateLinkScope resources. + KubernetesConfigurationPrivateLinkScopeListResult +} + +// ClientListResponse contains the response from method Client.NewListPager. +type ClientListResponse struct { + // Describes the list of Azure Arc PrivateLinkScope resources. + KubernetesConfigurationPrivateLinkScopeListResult +} + +// ClientUpdateTagsResponse contains the response from method Client.UpdateTags. +type ClientUpdateTagsResponse struct { + // An Azure Arc PrivateLinkScope definition. + KubernetesConfigurationPrivateLinkScope +} + +// PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.BeginCreateOrUpdate. +type PrivateEndpointConnectionsClientCreateOrUpdateResponse struct { + // The Private Endpoint Connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.Delete. +type PrivateEndpointConnectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. +type PrivateEndpointConnectionsClientGetResponse struct { + // The Private Endpoint Connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse contains the response from method PrivateEndpointConnectionsClient.ListByPrivateLinkScope. +type PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse struct { + // List of private endpoint connection associated with the specified storage account + PrivateEndpointConnectionListResult +} + +// PrivateLinkResourcesClientGetResponse contains the response from method PrivateLinkResourcesClient.Get. +type PrivateLinkResourcesClientGetResponse struct { + // A private link resource + PrivateLinkResource +} + +// PrivateLinkResourcesClientListByPrivateLinkScopeResponse contains the response from method PrivateLinkResourcesClient.ListByPrivateLinkScope. +type PrivateLinkResourcesClientListByPrivateLinkScopeResponse struct { + // A list of private link resources + PrivateLinkResourceListResult +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/time_rfc3339.go b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/time_rfc3339.go new file mode 100644 index 000000000000..eb4ab2a0794b --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armprivatelinkscopes/time_rfc3339.go @@ -0,0 +1,110 @@ +// 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 armprivatelinkscopes + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}