diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/CHANGELOG.md b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/CHANGELOG.md new file mode 100644 index 000000000000..ab4c3a2a9bd2 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-06-10) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/LICENSE.txt b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/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/delegatednetwork/armdelegatednetwork/README.md b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/README.md new file mode 100644 index 000000000000..89df514554f9 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/README.md @@ -0,0 +1,77 @@ +# Azure Delegatednetwork Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/delegatednetwork/armdelegatednetwork)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/delegatednetwork/armdelegatednetwork) + +The `armdelegatednetwork` module provides operations for working with Azure Delegatednetwork. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/delegatednetwork/armdelegatednetwork) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Delegatednetwork module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/delegatednetwork/armdelegatednetwork +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Delegatednetwork. 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). + +## Clients + +Azure Delegatednetwork modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armdelegatednetwork.NewDelegatedSubnetServiceClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armdelegatednetwork.NewDelegatedSubnetServiceClient(, cred, &options) +``` + +## 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 `Delegatednetwork` 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/delegatednetwork/armdelegatednetwork/autorest.md b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/autorest.md new file mode 100644 index 000000000000..db3c7010c817 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/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/dnc/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dnc/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/build.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/build.go new file mode 100644 index 000000000000..ac4a561c3274 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/delegatednetwork/armdelegatednetwork + +package armdelegatednetwork diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/ci.yml b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/ci.yml new file mode 100644 index 000000000000..0320805394be --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/delegatednetwork/armdelegatednetwork/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/delegatednetwork/armdelegatednetwork/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/delegatednetwork/armdelegatednetwork' diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.mod b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.mod new file mode 100644 index 000000000000..a790fb3bbfcd --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/delegatednetwork/armdelegatednetwork + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.sum b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.sum new file mode 100644 index 000000000000..3f874a3bc5a6 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_client.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_client.go new file mode 100644 index 000000000000..b33f5d4992b9 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_client.go @@ -0,0 +1,178 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// Client contains the methods for the DelegatedNetwork group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// 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) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListByResourceGroupPager - Get all the delegatedController resources in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controllers" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + 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.DelegatedControllers); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Get all the delegatedController resources in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// options - ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ + More: func(page ClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBySubscriptionResponse) (ClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, options *ClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DelegatedNetwork/controllers" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (ClientListBySubscriptionResponse, error) { + result := ClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedControllers); err != nil { + return ClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_constants.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_constants.go new file mode 100644 index 000000000000..5b54441eeac6 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_constants.go @@ -0,0 +1,138 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +const ( + moduleName = "armdelegatednetwork" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ControllerState - The current state of dnc controller resource. +type ControllerState string + +const ( + ControllerStateDeleting ControllerState = "Deleting" + ControllerStateFailed ControllerState = "Failed" + ControllerStateProvisioning ControllerState = "Provisioning" + ControllerStateSucceeded ControllerState = "Succeeded" +) + +// PossibleControllerStateValues returns the possible values for the ControllerState const type. +func PossibleControllerStateValues() []ControllerState { + return []ControllerState{ + ControllerStateDeleting, + ControllerStateFailed, + ControllerStateProvisioning, + ControllerStateSucceeded, + } +} + +// DelegatedSubnetState - The current state of dnc delegated subnet resource. +type DelegatedSubnetState string + +const ( + DelegatedSubnetStateDeleting DelegatedSubnetState = "Deleting" + DelegatedSubnetStateFailed DelegatedSubnetState = "Failed" + DelegatedSubnetStateProvisioning DelegatedSubnetState = "Provisioning" + DelegatedSubnetStateSucceeded DelegatedSubnetState = "Succeeded" +) + +// PossibleDelegatedSubnetStateValues returns the possible values for the DelegatedSubnetState const type. +func PossibleDelegatedSubnetStateValues() []DelegatedSubnetState { + return []DelegatedSubnetState{ + DelegatedSubnetStateDeleting, + DelegatedSubnetStateFailed, + DelegatedSubnetStateProvisioning, + DelegatedSubnetStateSucceeded, + } +} + +// OrchestratorInstanceState - The current state of orchestratorInstance resource. +type OrchestratorInstanceState string + +const ( + OrchestratorInstanceStateDeleting OrchestratorInstanceState = "Deleting" + OrchestratorInstanceStateFailed OrchestratorInstanceState = "Failed" + OrchestratorInstanceStateProvisioning OrchestratorInstanceState = "Provisioning" + OrchestratorInstanceStateSucceeded OrchestratorInstanceState = "Succeeded" +) + +// PossibleOrchestratorInstanceStateValues returns the possible values for the OrchestratorInstanceState const type. +func PossibleOrchestratorInstanceStateValues() []OrchestratorInstanceState { + return []OrchestratorInstanceState{ + OrchestratorInstanceStateDeleting, + OrchestratorInstanceStateFailed, + OrchestratorInstanceStateProvisioning, + OrchestratorInstanceStateSucceeded, + } +} + +// OrchestratorKind - The kind of workbook. Choices are user and shared. +type OrchestratorKind string + +const ( + OrchestratorKindKubernetes OrchestratorKind = "Kubernetes" +) + +// PossibleOrchestratorKindValues returns the possible values for the OrchestratorKind const type. +func PossibleOrchestratorKindValues() []OrchestratorKind { + return []OrchestratorKind{ + OrchestratorKindKubernetes, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ResourceIdentityType - The type of identity used for orchestrator cluster. Type 'SystemAssigned' will use an implicitly +// created identity orchestrator clusters +type ResourceIdentityType string + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeNone ResourceIdentityType = "None" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeNone, + } +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_controller_client.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_controller_client.go new file mode 100644 index 000000000000..98f63d02ff9b --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_controller_client.go @@ -0,0 +1,293 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ControllerClient contains the methods for the Controller group. +// Don't use this type directly, use NewControllerClient() instead. +type ControllerClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewControllerClient creates a new instance of ControllerClient 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 NewControllerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ControllerClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ControllerClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create a dnc controller +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - controller type parameters +// options - ControllerClientBeginCreateOptions contains the optional parameters for the ControllerClient.BeginCreate method. +func (client *ControllerClient) BeginCreate(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedController, options *ControllerClientBeginCreateOptions) (*runtime.Poller[ControllerClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[ControllerClientCreateResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[ControllerClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create a dnc controller +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *ControllerClient) create(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedController, options *ControllerClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ControllerClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedController, options *ControllerClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Deletes the DNC controller +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - ControllerClientBeginDeleteOptions contains the optional parameters for the ControllerClient.BeginDelete method. +func (client *ControllerClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *ControllerClientBeginDeleteOptions) (*runtime.Poller[ControllerClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[ControllerClientDeleteResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[ControllerClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes the DNC controller +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *ControllerClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *ControllerClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ControllerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ControllerClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetDetails - Gets details about the specified dnc controller. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - ControllerClientGetDetailsOptions contains the optional parameters for the ControllerClient.GetDetails method. +func (client *ControllerClient) GetDetails(ctx context.Context, resourceGroupName string, resourceName string, options *ControllerClientGetDetailsOptions) (ControllerClientGetDetailsResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return ControllerClientGetDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ControllerClientGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ControllerClientGetDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *ControllerClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ControllerClientGetDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *ControllerClient) getDetailsHandleResponse(resp *http.Response) (ControllerClientGetDetailsResponse, error) { + result := ControllerClientGetDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedController); err != nil { + return ControllerClientGetDetailsResponse{}, err + } + return result, nil +} + +// Patch - Update dnc controller +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - controller type parameters +// options - ControllerClientPatchOptions contains the optional parameters for the ControllerClient.Patch method. +func (client *ControllerClient) Patch(ctx context.Context, resourceGroupName string, resourceName string, parameters ControllerResourceUpdateParameters, options *ControllerClientPatchOptions) (ControllerClientPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return ControllerClientPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ControllerClientPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ControllerClientPatchResponse{}, runtime.NewResponseError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *ControllerClient) patchCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters ControllerResourceUpdateParameters, options *ControllerClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// patchHandleResponse handles the Patch response. +func (client *ControllerClient) patchHandleResponse(resp *http.Response) (ControllerClientPatchResponse, error) { + result := ControllerClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedController); err != nil { + return ControllerClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_delegatedsubnetservice_client.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_delegatedsubnetservice_client.go new file mode 100644 index 000000000000..eccbe4b411b8 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_delegatedsubnetservice_client.go @@ -0,0 +1,432 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DelegatedSubnetServiceClient contains the methods for the DelegatedSubnetService group. +// Don't use this type directly, use NewDelegatedSubnetServiceClient() instead. +type DelegatedSubnetServiceClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewDelegatedSubnetServiceClient creates a new instance of DelegatedSubnetServiceClient 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 NewDelegatedSubnetServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DelegatedSubnetServiceClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &DelegatedSubnetServiceClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginDeleteDetails - Delete dnc DelegatedSubnet. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - DelegatedSubnetServiceClientBeginDeleteDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginDeleteDetails +// method. +func (client *DelegatedSubnetServiceClient) BeginDeleteDetails(ctx context.Context, resourceGroupName string, resourceName string, options *DelegatedSubnetServiceClientBeginDeleteDetailsOptions) (*runtime.Poller[DelegatedSubnetServiceClientDeleteDetailsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteDetails(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[DelegatedSubnetServiceClientDeleteDetailsResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[DelegatedSubnetServiceClientDeleteDetailsResponse](options.ResumeToken, client.pl, nil) + } +} + +// DeleteDetails - Delete dnc DelegatedSubnet. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *DelegatedSubnetServiceClient) deleteDetails(ctx context.Context, resourceGroupName string, resourceName string, options *DelegatedSubnetServiceClientBeginDeleteDetailsOptions) (*http.Response, error) { + req, err := client.deleteDetailsCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteDetailsCreateRequest creates the DeleteDetails request. +func (client *DelegatedSubnetServiceClient) deleteDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *DelegatedSubnetServiceClientBeginDeleteDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + 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 +} + +// GetDetails - Gets details about the specified dnc DelegatedSubnet Link. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - DelegatedSubnetServiceClientGetDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.GetDetails +// method. +func (client *DelegatedSubnetServiceClient) GetDetails(ctx context.Context, resourceGroupName string, resourceName string, options *DelegatedSubnetServiceClientGetDetailsOptions) (DelegatedSubnetServiceClientGetDetailsResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return DelegatedSubnetServiceClientGetDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DelegatedSubnetServiceClientGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DelegatedSubnetServiceClientGetDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *DelegatedSubnetServiceClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *DelegatedSubnetServiceClientGetDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *DelegatedSubnetServiceClient) getDetailsHandleResponse(resp *http.Response) (DelegatedSubnetServiceClientGetDetailsResponse, error) { + result := DelegatedSubnetServiceClientGetDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedSubnet); err != nil { + return DelegatedSubnetServiceClientGetDetailsResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Get all the DelegatedSubnets resources in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - DelegatedSubnetServiceClientListByResourceGroupOptions contains the optional parameters for the DelegatedSubnetServiceClient.ListByResourceGroup +// method. +func (client *DelegatedSubnetServiceClient) NewListByResourceGroupPager(resourceGroupName string, options *DelegatedSubnetServiceClientListByResourceGroupOptions) *runtime.Pager[DelegatedSubnetServiceClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DelegatedSubnetServiceClientListByResourceGroupResponse]{ + More: func(page DelegatedSubnetServiceClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DelegatedSubnetServiceClientListByResourceGroupResponse) (DelegatedSubnetServiceClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DelegatedSubnetServiceClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DelegatedSubnetServiceClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DelegatedSubnetServiceClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DelegatedSubnetServiceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DelegatedSubnetServiceClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DelegatedSubnetServiceClient) listByResourceGroupHandleResponse(resp *http.Response) (DelegatedSubnetServiceClientListByResourceGroupResponse, error) { + result := DelegatedSubnetServiceClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedSubnets); err != nil { + return DelegatedSubnetServiceClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Get all the DelegatedSubnets resources in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// options - DelegatedSubnetServiceClientListBySubscriptionOptions contains the optional parameters for the DelegatedSubnetServiceClient.ListBySubscription +// method. +func (client *DelegatedSubnetServiceClient) NewListBySubscriptionPager(options *DelegatedSubnetServiceClientListBySubscriptionOptions) *runtime.Pager[DelegatedSubnetServiceClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DelegatedSubnetServiceClientListBySubscriptionResponse]{ + More: func(page DelegatedSubnetServiceClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DelegatedSubnetServiceClientListBySubscriptionResponse) (DelegatedSubnetServiceClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DelegatedSubnetServiceClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DelegatedSubnetServiceClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DelegatedSubnetServiceClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DelegatedSubnetServiceClient) listBySubscriptionCreateRequest(ctx context.Context, options *DelegatedSubnetServiceClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DelegatedNetwork/delegatedSubnets" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DelegatedSubnetServiceClient) listBySubscriptionHandleResponse(resp *http.Response) (DelegatedSubnetServiceClientListBySubscriptionResponse, error) { + result := DelegatedSubnetServiceClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DelegatedSubnets); err != nil { + return DelegatedSubnetServiceClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginPatchDetails - Patch delegated subnet resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - Delegated subnet details. +// options - DelegatedSubnetServiceClientBeginPatchDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginPatchDetails +// method. +func (client *DelegatedSubnetServiceClient) BeginPatchDetails(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceUpdateParameters, options *DelegatedSubnetServiceClientBeginPatchDetailsOptions) (*runtime.Poller[DelegatedSubnetServiceClientPatchDetailsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.patchDetails(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[DelegatedSubnetServiceClientPatchDetailsResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[DelegatedSubnetServiceClientPatchDetailsResponse](options.ResumeToken, client.pl, nil) + } +} + +// PatchDetails - Patch delegated subnet resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *DelegatedSubnetServiceClient) patchDetails(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceUpdateParameters, options *DelegatedSubnetServiceClientBeginPatchDetailsOptions) (*http.Response, error) { + req, err := client.patchDetailsCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// patchDetailsCreateRequest creates the PatchDetails request. +func (client *DelegatedSubnetServiceClient) patchDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceUpdateParameters, options *DelegatedSubnetServiceClientBeginPatchDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginPutDetails - Put delegated subnet resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - Delegated subnet details. +// options - DelegatedSubnetServiceClientBeginPutDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginPutDetails +// method. +func (client *DelegatedSubnetServiceClient) BeginPutDetails(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedSubnet, options *DelegatedSubnetServiceClientBeginPutDetailsOptions) (*runtime.Poller[DelegatedSubnetServiceClientPutDetailsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.putDetails(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[DelegatedSubnetServiceClientPutDetailsResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[DelegatedSubnetServiceClientPutDetailsResponse](options.ResumeToken, client.pl, nil) + } +} + +// PutDetails - Put delegated subnet resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *DelegatedSubnetServiceClient) putDetails(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedSubnet, options *DelegatedSubnetServiceClientBeginPutDetailsOptions) (*http.Response, error) { + req, err := client.putDetailsCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// putDetailsCreateRequest creates the PutDetails request. +func (client *DelegatedSubnetServiceClient) putDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters DelegatedSubnet, options *DelegatedSubnetServiceClientBeginPutDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models.go new file mode 100644 index 000000000000..682a592a128c --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models.go @@ -0,0 +1,468 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. +type ClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +type ClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ControllerClientBeginCreateOptions contains the optional parameters for the ControllerClient.BeginCreate method. +type ControllerClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ControllerClientBeginDeleteOptions contains the optional parameters for the ControllerClient.BeginDelete method. +type ControllerClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ControllerClientGetDetailsOptions contains the optional parameters for the ControllerClient.GetDetails method. +type ControllerClientGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// ControllerClientPatchOptions contains the optional parameters for the ControllerClient.Patch method. +type ControllerClientPatchOptions struct { + // placeholder for future optional parameters +} + +// ControllerDetails - controller details +type ControllerDetails struct { + // controller arm resource id + ID *string `json:"id,omitempty"` +} + +// ControllerResource - Represents an instance of a resource. +type ControllerResource struct { + // Location of the resource. + Location *string `json:"location,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ControllerResourceUpdateParameters - Parameters for updating a resource. +type ControllerResourceUpdateParameters struct { + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// DelegatedController - Represents an instance of a DNC controller. +type DelegatedController struct { + // Location of the resource. + Location *string `json:"location,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Properties of the provision operation request. + Properties *DelegatedControllerProperties `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DelegatedControllerProperties - Properties of Delegated controller resource. +type DelegatedControllerProperties struct { + // READ-ONLY; dnc application id should be used by customer to authenticate with dnc gateway. + DncAppID *string `json:"dncAppId,omitempty" azure:"ro"` + + // READ-ONLY; dnc endpoint url that customers can use to connect to + DncEndpoint *string `json:"dncEndpoint,omitempty" azure:"ro"` + + // READ-ONLY; tenant id of dnc application id + DncTenantID *string `json:"dncTenantId,omitempty" azure:"ro"` + + // READ-ONLY; The current state of dnc controller resource. + ProvisioningState *ControllerState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Resource guid. + ResourceGUID *string `json:"resourceGuid,omitempty" azure:"ro"` +} + +// DelegatedControllers - An array of Delegated controller resources. +type DelegatedControllers struct { + // REQUIRED; An array of Delegated controller resources. + Value []*DelegatedController `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of controllers. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// DelegatedSubnet - Represents an instance of a orchestrator. +type DelegatedSubnet struct { + // Location of the resource. + Location *string `json:"location,omitempty"` + + // Properties of the provision operation request. + Properties *DelegatedSubnetProperties `json:"properties,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DelegatedSubnetProperties - Properties of delegated subnet +type DelegatedSubnetProperties struct { + // Properties of the controller. + ControllerDetails *ControllerDetails `json:"controllerDetails,omitempty"` + + // subnet details + SubnetDetails *SubnetDetails `json:"subnetDetails,omitempty"` + + // READ-ONLY; The current state of dnc delegated subnet resource. + ProvisioningState *DelegatedSubnetState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Resource guid. + ResourceGUID *string `json:"resourceGuid,omitempty" azure:"ro"` +} + +// DelegatedSubnetResource - Represents an instance of a resource. +type DelegatedSubnetResource struct { + // Location of the resource. + Location *string `json:"location,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DelegatedSubnetServiceClientBeginDeleteDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginDeleteDetails +// method. +type DelegatedSubnetServiceClientBeginDeleteDetailsOptions struct { + // Force delete resource + ForceDelete *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DelegatedSubnetServiceClientBeginPatchDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginPatchDetails +// method. +type DelegatedSubnetServiceClientBeginPatchDetailsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DelegatedSubnetServiceClientBeginPutDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.BeginPutDetails +// method. +type DelegatedSubnetServiceClientBeginPutDetailsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DelegatedSubnetServiceClientGetDetailsOptions contains the optional parameters for the DelegatedSubnetServiceClient.GetDetails +// method. +type DelegatedSubnetServiceClientGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// DelegatedSubnetServiceClientListByResourceGroupOptions contains the optional parameters for the DelegatedSubnetServiceClient.ListByResourceGroup +// method. +type DelegatedSubnetServiceClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DelegatedSubnetServiceClientListBySubscriptionOptions contains the optional parameters for the DelegatedSubnetServiceClient.ListBySubscription +// method. +type DelegatedSubnetServiceClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DelegatedSubnets - An array of DelegatedSubnet resources. +type DelegatedSubnets struct { + // REQUIRED; An array of DelegatedSubnet resources. + Value []*DelegatedSubnet `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of DelegatedSubnet resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// Orchestrator - Represents an instance of a orchestrator. +type Orchestrator struct { + // REQUIRED; The kind of workbook. Choices are user and shared. + Kind *OrchestratorKind `json:"kind,omitempty"` + + // The identity of the orchestrator + Identity *OrchestratorIdentity `json:"identity,omitempty"` + + // Location of the resource. + Location *string `json:"location,omitempty"` + + // Properties of the provision operation request. + Properties *OrchestratorResourceProperties `json:"properties,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +type OrchestratorIdentity struct { + // The type of identity used for orchestrator cluster. Type 'SystemAssigned' will use an implicitly created identity orchestrator + // clusters + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal id of the system assigned identity which is used by orchestrator. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant id of the system assigned identity which is used by orchestrator. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// OrchestratorInstanceServiceClientBeginCreateOptions contains the optional parameters for the OrchestratorInstanceServiceClient.BeginCreate +// method. +type OrchestratorInstanceServiceClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OrchestratorInstanceServiceClientBeginDeleteOptions contains the optional parameters for the OrchestratorInstanceServiceClient.BeginDelete +// method. +type OrchestratorInstanceServiceClientBeginDeleteOptions struct { + // Force delete resource + ForceDelete *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OrchestratorInstanceServiceClientGetDetailsOptions contains the optional parameters for the OrchestratorInstanceServiceClient.GetDetails +// method. +type OrchestratorInstanceServiceClientGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// OrchestratorInstanceServiceClientListByResourceGroupOptions contains the optional parameters for the OrchestratorInstanceServiceClient.ListByResourceGroup +// method. +type OrchestratorInstanceServiceClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// OrchestratorInstanceServiceClientListBySubscriptionOptions contains the optional parameters for the OrchestratorInstanceServiceClient.ListBySubscription +// method. +type OrchestratorInstanceServiceClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// OrchestratorInstanceServiceClientPatchOptions contains the optional parameters for the OrchestratorInstanceServiceClient.Patch +// method. +type OrchestratorInstanceServiceClientPatchOptions struct { + // placeholder for future optional parameters +} + +// OrchestratorResource - Represents an instance of a resource. +type OrchestratorResource struct { + // REQUIRED; The kind of workbook. Choices are user and shared. + Kind *OrchestratorKind `json:"kind,omitempty"` + + // The identity of the orchestrator + Identity *OrchestratorIdentity `json:"identity,omitempty"` + + // Location of the resource. + Location *string `json:"location,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; An identifier that represents the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// OrchestratorResourceProperties - Properties of orchestrator +type OrchestratorResourceProperties struct { + // REQUIRED; Properties of the controller. + ControllerDetails *ControllerDetails `json:"controllerDetails,omitempty"` + + // K8s APIServer url. Either one of apiServerEndpoint or privateLinkResourceId can be specified + APIServerEndpoint *string `json:"apiServerEndpoint,omitempty"` + + // RootCA certificate of kubernetes cluster base64 encoded + ClusterRootCA *string `json:"clusterRootCA,omitempty"` + + // AAD ID used with apiserver + OrchestratorAppID *string `json:"orchestratorAppId,omitempty"` + + // TenantID of server App ID + OrchestratorTenantID *string `json:"orchestratorTenantId,omitempty"` + + // private link arm resource id. Either one of apiServerEndpoint or privateLinkResourceId can be specified + PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"` + + // READ-ONLY; The current state of orchestratorInstance resource. + ProvisioningState *OrchestratorInstanceState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Resource guid. + ResourceGUID *string `json:"resourceGuid,omitempty" azure:"ro"` +} + +// OrchestratorResourceUpdateParameters - Parameters for updating a resource. +type OrchestratorResourceUpdateParameters struct { + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// Orchestrators - An array of OrchestratorInstance resources. +type Orchestrators struct { + // REQUIRED; An array of OrchestratorInstance resources. + Value []*Orchestrator `json:"value,omitempty"` + + // READ-ONLY; The URL to get the next set of orchestrators. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// ResourceUpdateParameters - Parameters for updating a resource. +type ResourceUpdateParameters struct { + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// SubnetDetails - Properties of orchestrator +type SubnetDetails struct { + // subnet arm resource id + ID *string `json:"id,omitempty"` +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models_serde.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models_serde.go new file mode 100644 index 000000000000..2a17c02f36e5 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_models_serde.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ControllerResource. +func (c ControllerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ControllerResourceUpdateParameters. +func (c ControllerResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type DelegatedController. +func (d DelegatedController) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type DelegatedSubnet. +func (d DelegatedSubnet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type DelegatedSubnetResource. +func (d DelegatedSubnetResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type Orchestrator. +func (o Orchestrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", o.ID) + populate(objectMap, "identity", o.Identity) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "tags", o.Tags) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type OrchestratorResource. +func (o OrchestratorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", o.ID) + populate(objectMap, "identity", o.Identity) + populate(objectMap, "kind", o.Kind) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "tags", o.Tags) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type OrchestratorResourceUpdateParameters. +func (o OrchestratorResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", o.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceUpdateParameters. +func (r ResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_operations_client.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_operations_client.go new file mode 100644 index 000000000000..677ba61c2ccb --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_operations_client.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - Lists all of the available DelegatedNetwork service REST API operations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.DelegatedNetwork/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_orchestratorinstanceservice_client.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_orchestratorinstanceservice_client.go new file mode 100644 index 000000000000..18493afc3993 --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_orchestratorinstanceservice_client.go @@ -0,0 +1,426 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// OrchestratorInstanceServiceClient contains the methods for the OrchestratorInstanceService group. +// Don't use this type directly, use NewOrchestratorInstanceServiceClient() instead. +type OrchestratorInstanceServiceClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewOrchestratorInstanceServiceClient creates a new instance of OrchestratorInstanceServiceClient 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 NewOrchestratorInstanceServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrchestratorInstanceServiceClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OrchestratorInstanceServiceClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create a orchestrator instance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - OrchestratorInstance type parameters +// options - OrchestratorInstanceServiceClientBeginCreateOptions contains the optional parameters for the OrchestratorInstanceServiceClient.BeginCreate +// method. +func (client *OrchestratorInstanceServiceClient) BeginCreate(ctx context.Context, resourceGroupName string, resourceName string, parameters Orchestrator, options *OrchestratorInstanceServiceClientBeginCreateOptions) (*runtime.Poller[OrchestratorInstanceServiceClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[OrchestratorInstanceServiceClientCreateResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[OrchestratorInstanceServiceClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create a orchestrator instance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *OrchestratorInstanceServiceClient) create(ctx context.Context, resourceGroupName string, resourceName string, parameters Orchestrator, options *OrchestratorInstanceServiceClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *OrchestratorInstanceServiceClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Orchestrator, options *OrchestratorInstanceServiceClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/orchestrators/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Deletes the Orchestrator Instance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - OrchestratorInstanceServiceClientBeginDeleteOptions contains the optional parameters for the OrchestratorInstanceServiceClient.BeginDelete +// method. +func (client *OrchestratorInstanceServiceClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *OrchestratorInstanceServiceClientBeginDeleteOptions) (*runtime.Poller[OrchestratorInstanceServiceClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[OrchestratorInstanceServiceClientDeleteResponse](resp, client.pl, nil) + } else { + return runtime.NewPollerFromResumeToken[OrchestratorInstanceServiceClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes the Orchestrator Instance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +func (client *OrchestratorInstanceServiceClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *OrchestratorInstanceServiceClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *OrchestratorInstanceServiceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *OrchestratorInstanceServiceClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/orchestrators/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + 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 +} + +// GetDetails - Gets details about the orchestrator instance. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// options - OrchestratorInstanceServiceClientGetDetailsOptions contains the optional parameters for the OrchestratorInstanceServiceClient.GetDetails +// method. +func (client *OrchestratorInstanceServiceClient) GetDetails(ctx context.Context, resourceGroupName string, resourceName string, options *OrchestratorInstanceServiceClientGetDetailsOptions) (OrchestratorInstanceServiceClientGetDetailsResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return OrchestratorInstanceServiceClientGetDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OrchestratorInstanceServiceClientGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OrchestratorInstanceServiceClientGetDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *OrchestratorInstanceServiceClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *OrchestratorInstanceServiceClientGetDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/orchestrators/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *OrchestratorInstanceServiceClient) getDetailsHandleResponse(resp *http.Response) (OrchestratorInstanceServiceClientGetDetailsResponse, error) { + result := OrchestratorInstanceServiceClientGetDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Orchestrator); err != nil { + return OrchestratorInstanceServiceClientGetDetailsResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Get all the OrchestratorInstances resources in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - OrchestratorInstanceServiceClientListByResourceGroupOptions contains the optional parameters for the OrchestratorInstanceServiceClient.ListByResourceGroup +// method. +func (client *OrchestratorInstanceServiceClient) NewListByResourceGroupPager(resourceGroupName string, options *OrchestratorInstanceServiceClientListByResourceGroupOptions) *runtime.Pager[OrchestratorInstanceServiceClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[OrchestratorInstanceServiceClientListByResourceGroupResponse]{ + More: func(page OrchestratorInstanceServiceClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OrchestratorInstanceServiceClientListByResourceGroupResponse) (OrchestratorInstanceServiceClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OrchestratorInstanceServiceClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OrchestratorInstanceServiceClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OrchestratorInstanceServiceClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *OrchestratorInstanceServiceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *OrchestratorInstanceServiceClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/orchestrators" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *OrchestratorInstanceServiceClient) listByResourceGroupHandleResponse(resp *http.Response) (OrchestratorInstanceServiceClientListByResourceGroupResponse, error) { + result := OrchestratorInstanceServiceClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Orchestrators); err != nil { + return OrchestratorInstanceServiceClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Get all the orchestratorInstance resources in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// options - OrchestratorInstanceServiceClientListBySubscriptionOptions contains the optional parameters for the OrchestratorInstanceServiceClient.ListBySubscription +// method. +func (client *OrchestratorInstanceServiceClient) NewListBySubscriptionPager(options *OrchestratorInstanceServiceClientListBySubscriptionOptions) *runtime.Pager[OrchestratorInstanceServiceClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[OrchestratorInstanceServiceClientListBySubscriptionResponse]{ + More: func(page OrchestratorInstanceServiceClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OrchestratorInstanceServiceClientListBySubscriptionResponse) (OrchestratorInstanceServiceClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OrchestratorInstanceServiceClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OrchestratorInstanceServiceClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OrchestratorInstanceServiceClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *OrchestratorInstanceServiceClient) listBySubscriptionCreateRequest(ctx context.Context, options *OrchestratorInstanceServiceClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DelegatedNetwork/orchestrators" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *OrchestratorInstanceServiceClient) listBySubscriptionHandleResponse(resp *http.Response) (OrchestratorInstanceServiceClientListBySubscriptionResponse, error) { + result := OrchestratorInstanceServiceClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Orchestrators); err != nil { + return OrchestratorInstanceServiceClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Patch - Update Orchestrator Instance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-03-15 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - The name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// parameters - OrchestratorInstance update parameters +// options - OrchestratorInstanceServiceClientPatchOptions contains the optional parameters for the OrchestratorInstanceServiceClient.Patch +// method. +func (client *OrchestratorInstanceServiceClient) Patch(ctx context.Context, resourceGroupName string, resourceName string, parameters OrchestratorResourceUpdateParameters, options *OrchestratorInstanceServiceClientPatchOptions) (OrchestratorInstanceServiceClientPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return OrchestratorInstanceServiceClientPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OrchestratorInstanceServiceClientPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OrchestratorInstanceServiceClientPatchResponse{}, runtime.NewResponseError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *OrchestratorInstanceServiceClient) patchCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters OrchestratorResourceUpdateParameters, options *OrchestratorInstanceServiceClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/orchestrators/{resourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-03-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// patchHandleResponse handles the Patch response. +func (client *OrchestratorInstanceServiceClient) patchHandleResponse(resp *http.Response) (OrchestratorInstanceServiceClientPatchResponse, error) { + result := OrchestratorInstanceServiceClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Orchestrator); err != nil { + return OrchestratorInstanceServiceClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_response_types.go b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_response_types.go new file mode 100644 index 000000000000..ec5e592ff93e --- /dev/null +++ b/sdk/resourcemanager/delegatednetwork/armdelegatednetwork/zz_generated_response_types.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdelegatednetwork + +// ClientListByResourceGroupResponse contains the response from method Client.ListByResourceGroup. +type ClientListByResourceGroupResponse struct { + DelegatedControllers +} + +// ClientListBySubscriptionResponse contains the response from method Client.ListBySubscription. +type ClientListBySubscriptionResponse struct { + DelegatedControllers +} + +// ControllerClientCreateResponse contains the response from method ControllerClient.Create. +type ControllerClientCreateResponse struct { + DelegatedController +} + +// ControllerClientDeleteResponse contains the response from method ControllerClient.Delete. +type ControllerClientDeleteResponse struct { + // placeholder for future response values +} + +// ControllerClientGetDetailsResponse contains the response from method ControllerClient.GetDetails. +type ControllerClientGetDetailsResponse struct { + DelegatedController +} + +// ControllerClientPatchResponse contains the response from method ControllerClient.Patch. +type ControllerClientPatchResponse struct { + DelegatedController +} + +// DelegatedSubnetServiceClientDeleteDetailsResponse contains the response from method DelegatedSubnetServiceClient.DeleteDetails. +type DelegatedSubnetServiceClientDeleteDetailsResponse struct { + // placeholder for future response values +} + +// DelegatedSubnetServiceClientGetDetailsResponse contains the response from method DelegatedSubnetServiceClient.GetDetails. +type DelegatedSubnetServiceClientGetDetailsResponse struct { + DelegatedSubnet +} + +// DelegatedSubnetServiceClientListByResourceGroupResponse contains the response from method DelegatedSubnetServiceClient.ListByResourceGroup. +type DelegatedSubnetServiceClientListByResourceGroupResponse struct { + DelegatedSubnets +} + +// DelegatedSubnetServiceClientListBySubscriptionResponse contains the response from method DelegatedSubnetServiceClient.ListBySubscription. +type DelegatedSubnetServiceClientListBySubscriptionResponse struct { + DelegatedSubnets +} + +// DelegatedSubnetServiceClientPatchDetailsResponse contains the response from method DelegatedSubnetServiceClient.PatchDetails. +type DelegatedSubnetServiceClientPatchDetailsResponse struct { + DelegatedSubnet +} + +// DelegatedSubnetServiceClientPutDetailsResponse contains the response from method DelegatedSubnetServiceClient.PutDetails. +type DelegatedSubnetServiceClientPutDetailsResponse struct { + DelegatedSubnet +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// OrchestratorInstanceServiceClientCreateResponse contains the response from method OrchestratorInstanceServiceClient.Create. +type OrchestratorInstanceServiceClientCreateResponse struct { + Orchestrator +} + +// OrchestratorInstanceServiceClientDeleteResponse contains the response from method OrchestratorInstanceServiceClient.Delete. +type OrchestratorInstanceServiceClientDeleteResponse struct { + // placeholder for future response values +} + +// OrchestratorInstanceServiceClientGetDetailsResponse contains the response from method OrchestratorInstanceServiceClient.GetDetails. +type OrchestratorInstanceServiceClientGetDetailsResponse struct { + Orchestrator +} + +// OrchestratorInstanceServiceClientListByResourceGroupResponse contains the response from method OrchestratorInstanceServiceClient.ListByResourceGroup. +type OrchestratorInstanceServiceClientListByResourceGroupResponse struct { + Orchestrators +} + +// OrchestratorInstanceServiceClientListBySubscriptionResponse contains the response from method OrchestratorInstanceServiceClient.ListBySubscription. +type OrchestratorInstanceServiceClientListBySubscriptionResponse struct { + Orchestrators +} + +// OrchestratorInstanceServiceClientPatchResponse contains the response from method OrchestratorInstanceServiceClient.Patch. +type OrchestratorInstanceServiceClientPatchResponse struct { + Orchestrator +}