diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/client.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/client.go new file mode 100644 index 000000000000..b85aa4c02105 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/client.go @@ -0,0 +1,52 @@ +// Package delegatednetwork implements the Azure ARM Delegatednetwork service API version 2020-08-08-preview. +// +// DNC web api provides way to create, get and delete dnc controller +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Delegatednetwork + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Delegatednetwork. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/controller.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/controller.go new file mode 100644 index 000000000000..0af3a7456376 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/controller.go @@ -0,0 +1,400 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ControllerClient is the DNC web api provides way to create, get and delete dnc controller +type ControllerClient struct { + BaseClient +} + +// NewControllerClient creates an instance of the ControllerClient client. +func NewControllerClient(subscriptionID string) ControllerClient { + return NewControllerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewControllerClientWithBaseURI creates an instance of the ControllerClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewControllerClientWithBaseURI(baseURI string, subscriptionID string) ControllerClient { + return ControllerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a dnc controller +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// controllerParameters - controller type parameters +func (client ControllerClient) Create(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters ControllerTypeParameters) (result ControllerCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ControllerClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.ControllerClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, controllerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ControllerClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters ControllerTypeParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}", pathParameters), + autorest.WithJSON(controllerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ControllerClient) CreateSender(req *http.Request) (future ControllerCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ControllerClient) CreateResponder(resp *http.Response) (result DelegatedController, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the DNC controller +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +func (client ControllerClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result ControllerDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ControllerClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.ControllerClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ControllerClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ControllerClient) DeleteSender(req *http.Request) (future ControllerDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ControllerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetDetails gets details about the specified dnc controller. +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +func (client ControllerClient) GetDetails(ctx context.Context, resourceGroupName string, resourceName string) (result DelegatedController, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ControllerClient.GetDetails") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.ControllerClient", "GetDetails", err.Error()) + } + + req, err := client.GetDetailsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "GetDetails", nil, "Failure preparing request") + return + } + + resp, err := client.GetDetailsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "GetDetails", resp, "Failure sending request") + return + } + + result, err = client.GetDetailsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "GetDetails", resp, "Failure responding to request") + } + + return +} + +// GetDetailsPreparer prepares the GetDetails request. +func (client ControllerClient) GetDetailsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDetailsSender sends the GetDetails request. The method will close the +// http.Response Body if it receives an error. +func (client ControllerClient) GetDetailsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDetailsResponder handles the response to the GetDetails request. The method always +// closes the http.Response Body. +func (client ControllerClient) GetDetailsResponder(resp *http.Response) (result DelegatedController, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Patch update dnc controller +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// controllerParameters - controller type parameters +func (client ControllerClient) Patch(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters ControllerTypeParameters) (result DelegatedController, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ControllerClient.Patch") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.ControllerClient", "Patch", err.Error()) + } + + req, err := client.PatchPreparer(ctx, resourceGroupName, resourceName, controllerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Patch", nil, "Failure preparing request") + return + } + + resp, err := client.PatchSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Patch", resp, "Failure sending request") + return + } + + result, err = client.PatchResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerClient", "Patch", resp, "Failure responding to request") + } + + return +} + +// PatchPreparer prepares the Patch request. +func (client ControllerClient) PatchPreparer(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters ControllerTypeParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/controller/{resourceName}", pathParameters), + autorest.WithJSON(controllerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PatchSender sends the Patch request. The method will close the +// http.Response Body if it receives an error. +func (client ControllerClient) PatchSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// PatchResponder handles the response to the Patch request. The method always +// closes the http.Response Body. +func (client ControllerClient) PatchResponder(resp *http.Response) (result DelegatedController, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetwork.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetwork.go new file mode 100644 index 000000000000..c9f5b57c6550 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetwork.go @@ -0,0 +1,195 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// Client is the DNC web api provides way to create, get and delete dnc controller +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByResourceGroup get all the delegatedController resources in a resource group. +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DelegatedControllers, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.Client", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedControllers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client Client) ListByResourceGroupResponder(resp *http.Response) (result DelegatedControllers, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get all the delegatedController resources in a subscription. +func (client Client) ListBySubscription(ctx context.Context) (result DelegatedControllers, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.Client", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DelegatedNetwork/delegatedControllers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client Client) ListBySubscriptionResponder(resp *http.Response) (result DelegatedControllers, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetworkapi/interfaces.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetworkapi/interfaces.go new file mode 100644 index 000000000000..6fc1cfee161d --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatednetworkapi/interfaces.go @@ -0,0 +1,61 @@ +package delegatednetworkapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork" +) + +// ControllerClientAPI contains the set of methods on the ControllerClient type. +type ControllerClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters delegatednetwork.ControllerTypeParameters) (result delegatednetwork.ControllerCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result delegatednetwork.ControllerDeleteFuture, err error) + GetDetails(ctx context.Context, resourceGroupName string, resourceName string) (result delegatednetwork.DelegatedController, err error) + Patch(ctx context.Context, resourceGroupName string, resourceName string, controllerParameters delegatednetwork.ControllerTypeParameters) (result delegatednetwork.DelegatedController, err error) +} + +var _ ControllerClientAPI = (*delegatednetwork.ControllerClient)(nil) + +// DelegatedSubnetServiceClientAPI contains the set of methods on the DelegatedSubnetServiceClient type. +type DelegatedSubnetServiceClientAPI interface { + DeleteDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (result delegatednetwork.DelegatedSubnetServiceDeleteDetailsFuture, err error) + GetDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (result delegatednetwork.DelegatedSubnet, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result delegatednetwork.DelegatedSubnetList, err error) + ListBySubscription(ctx context.Context) (result delegatednetwork.DelegatedSubnetList, err error) + PatchDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters delegatednetwork.DelegatedSubnetParameters) (result delegatednetwork.DelegatedSubnetServicePatchDetailsFuture, err error) + PutDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters delegatednetwork.DelegatedSubnetParameters) (result delegatednetwork.DelegatedSubnetServicePutDetailsFuture, err error) +} + +var _ DelegatedSubnetServiceClientAPI = (*delegatednetwork.DelegatedSubnetServiceClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result delegatednetwork.DelegatedControllers, err error) + ListBySubscription(ctx context.Context) (result delegatednetwork.DelegatedControllers, err error) +} + +var _ ClientAPI = (*delegatednetwork.Client)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result delegatednetwork.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result delegatednetwork.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*delegatednetwork.OperationsClient)(nil) diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatedsubnetservice.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatedsubnetservice.go new file mode 100644 index 000000000000..38677e2d87de --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/delegatedsubnetservice.go @@ -0,0 +1,609 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DelegatedSubnetServiceClient is the DNC web api provides way to create, get and delete dnc controller +type DelegatedSubnetServiceClient struct { + BaseClient +} + +// NewDelegatedSubnetServiceClient creates an instance of the DelegatedSubnetServiceClient client. +func NewDelegatedSubnetServiceClient(subscriptionID string) DelegatedSubnetServiceClient { + return NewDelegatedSubnetServiceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDelegatedSubnetServiceClientWithBaseURI creates an instance of the DelegatedSubnetServiceClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDelegatedSubnetServiceClientWithBaseURI(baseURI string, subscriptionID string) DelegatedSubnetServiceClient { + return DelegatedSubnetServiceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// DeleteDetails delete dnc DelegatedSubnet. +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// vnetName - the name of the virtual network. This name must be at least 1 character in length, and no more +// than 90. +// subnetName - the name of the delegated subnet. This name must be at least 1 character in length, and no more +// than 90. +func (client DelegatedSubnetServiceClient) DeleteDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (result DelegatedSubnetServiceDeleteDetailsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.DeleteDetails") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}, + {TargetValue: vnetName, + Constraints: []validation.Constraint{{Target: "vnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "vnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "vnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: subnetName, + Constraints: []validation.Constraint{{Target: "subnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "subnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "subnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.DelegatedSubnetServiceClient", "DeleteDetails", err.Error()) + } + + req, err := client.DeleteDetailsPreparer(ctx, resourceGroupName, resourceName, vnetName, subnetName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "DeleteDetails", nil, "Failure preparing request") + return + } + + result, err = client.DeleteDetailsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "DeleteDetails", result.Response(), "Failure sending request") + return + } + + return +} + +// DeleteDetailsPreparer prepares the DeleteDetails request. +func (client DelegatedSubnetServiceClient) DeleteDetailsPreparer(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vnetName": autorest.Encode("path", vnetName), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteDetailsSender sends the DeleteDetails request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) DeleteDetailsSender(req *http.Request) (future DelegatedSubnetServiceDeleteDetailsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteDetailsResponder handles the response to the DeleteDetails request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) DeleteDetailsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetDetails gets details about the specified dnc DelegatedSubnet Link. +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// vnetName - the name of the virtual network. This name must be at least 1 character in length, and no more +// than 90. +// subnetName - the name of the delegated subnet. This name must be at least 1 character in length, and no more +// than 90. +func (client DelegatedSubnetServiceClient) GetDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (result DelegatedSubnet, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.GetDetails") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}, + {TargetValue: vnetName, + Constraints: []validation.Constraint{{Target: "vnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "vnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "vnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: subnetName, + Constraints: []validation.Constraint{{Target: "subnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "subnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "subnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.DelegatedSubnetServiceClient", "GetDetails", err.Error()) + } + + req, err := client.GetDetailsPreparer(ctx, resourceGroupName, resourceName, vnetName, subnetName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "GetDetails", nil, "Failure preparing request") + return + } + + resp, err := client.GetDetailsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "GetDetails", resp, "Failure sending request") + return + } + + result, err = client.GetDetailsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "GetDetails", resp, "Failure responding to request") + } + + return +} + +// GetDetailsPreparer prepares the GetDetails request. +func (client DelegatedSubnetServiceClient) GetDetailsPreparer(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vnetName": autorest.Encode("path", vnetName), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDetailsSender sends the GetDetails request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) GetDetailsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDetailsResponder handles the response to the GetDetails request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) GetDetailsResponder(resp *http.Response) (result DelegatedSubnet, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get all the DelegatedSubnets resources in a resource group. +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +func (client DelegatedSubnetServiceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DelegatedSubnetList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.DelegatedSubnetServiceClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DelegatedSubnetServiceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DelegatedNetwork/delegatedSubnetInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) ListByResourceGroupResponder(resp *http.Response) (result DelegatedSubnetList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get all the DelegatedSubnets resources in a subscription. +func (client DelegatedSubnetServiceClient) ListBySubscription(ctx context.Context) (result DelegatedSubnetList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DelegatedSubnetServiceClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DelegatedNetwork/delegatedSubnetInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) ListBySubscriptionResponder(resp *http.Response) (result DelegatedSubnetList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// PatchDetails patch delegated subnet resource +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// vnetName - the name of the virtual network. This name must be at least 1 character in length, and no more +// than 90. +// subnetName - the name of the delegated subnet. This name must be at least 1 character in length, and no more +// than 90. +// delegatedSubnetParameters - delegated subnet details. +func (client DelegatedSubnetServiceClient) PatchDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters DelegatedSubnetParameters) (result DelegatedSubnetServicePatchDetailsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.PatchDetails") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}, + {TargetValue: vnetName, + Constraints: []validation.Constraint{{Target: "vnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "vnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "vnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: subnetName, + Constraints: []validation.Constraint{{Target: "subnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "subnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "subnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.DelegatedSubnetServiceClient", "PatchDetails", err.Error()) + } + + req, err := client.PatchDetailsPreparer(ctx, resourceGroupName, resourceName, vnetName, subnetName, delegatedSubnetParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "PatchDetails", nil, "Failure preparing request") + return + } + + result, err = client.PatchDetailsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "PatchDetails", result.Response(), "Failure sending request") + return + } + + return +} + +// PatchDetailsPreparer prepares the PatchDetails request. +func (client DelegatedSubnetServiceClient) PatchDetailsPreparer(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters DelegatedSubnetParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vnetName": autorest.Encode("path", vnetName), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}", pathParameters), + autorest.WithJSON(delegatedSubnetParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PatchDetailsSender sends the PatchDetails request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) PatchDetailsSender(req *http.Request) (future DelegatedSubnetServicePatchDetailsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PatchDetailsResponder handles the response to the PatchDetails request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) PatchDetailsResponder(resp *http.Response) (result DelegatedSubnet, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// PutDetails put delegated subnet resource +// Parameters: +// resourceGroupName - the name of the Azure Resource group of which a given DelegatedNetwork resource is part. +// This name must be at least 1 character in length, and no more than 90. +// resourceName - the name of the resource. It must be a minimum of 3 characters, and a maximum of 63. +// vnetName - the name of the virtual network. This name must be at least 1 character in length, and no more +// than 90. +// subnetName - the name of the delegated subnet. This name must be at least 1 character in length, and no more +// than 90. +// delegatedSubnetParameters - delegated subnet details. +func (client DelegatedSubnetServiceClient) PutDetails(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters DelegatedSubnetParameters) (result DelegatedSubnetServicePutDetailsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegatedSubnetServiceClient.PutDetails") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}, + {TargetValue: vnetName, + Constraints: []validation.Constraint{{Target: "vnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "vnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "vnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: subnetName, + Constraints: []validation.Constraint{{Target: "subnetName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "subnetName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "subnetName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("delegatednetwork.DelegatedSubnetServiceClient", "PutDetails", err.Error()) + } + + req, err := client.PutDetailsPreparer(ctx, resourceGroupName, resourceName, vnetName, subnetName, delegatedSubnetParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "PutDetails", nil, "Failure preparing request") + return + } + + result, err = client.PutDetailsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceClient", "PutDetails", result.Response(), "Failure sending request") + return + } + + return +} + +// PutDetailsPreparer prepares the PutDetails request. +func (client DelegatedSubnetServiceClient) PutDetailsPreparer(ctx context.Context, resourceGroupName string, resourceName string, vnetName string, subnetName string, delegatedSubnetParameters DelegatedSubnetParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vnetName": autorest.Encode("path", vnetName), + } + + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}/providers/Microsoft.DelegatedNetwork/delegatedSubnets/{resourceName}", pathParameters), + autorest.WithJSON(delegatedSubnetParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutDetailsSender sends the PutDetails request. The method will close the +// http.Response Body if it receives an error. +func (client DelegatedSubnetServiceClient) PutDetailsSender(req *http.Request) (future DelegatedSubnetServicePutDetailsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PutDetailsResponder handles the response to the PutDetails request. The method always +// closes the http.Response Body. +func (client DelegatedSubnetServiceClient) PutDetailsResponder(resp *http.Response) (result DelegatedSubnet, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/enums.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/enums.go new file mode 100644 index 000000000000..9964aeb14356 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/enums.go @@ -0,0 +1,56 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ControllerState enumerates the values for controller state. +type ControllerState string + +const ( + // Deleting ... + Deleting ControllerState = "Deleting" + // Failed ... + Failed ControllerState = "Failed" + // Provisioning ... + Provisioning ControllerState = "Provisioning" + // Succeeded ... + Succeeded ControllerState = "Succeeded" +) + +// PossibleControllerStateValues returns an array of possible values for the ControllerState const type. +func PossibleControllerStateValues() []ControllerState { + return []ControllerState{Deleting, Failed, Provisioning, Succeeded} +} + +// DelegatedSubnetState enumerates the values for delegated subnet state. +type DelegatedSubnetState string + +const ( + // DelegatedSubnetStateDeleting ... + DelegatedSubnetStateDeleting DelegatedSubnetState = "Deleting" + // DelegatedSubnetStateFailed ... + DelegatedSubnetStateFailed DelegatedSubnetState = "Failed" + // DelegatedSubnetStateProvisioning ... + DelegatedSubnetStateProvisioning DelegatedSubnetState = "Provisioning" + // DelegatedSubnetStateSucceeded ... + DelegatedSubnetStateSucceeded DelegatedSubnetState = "Succeeded" +) + +// PossibleDelegatedSubnetStateValues returns an array of possible values for the DelegatedSubnetState const type. +func PossibleDelegatedSubnetStateValues() []DelegatedSubnetState { + return []DelegatedSubnetState{DelegatedSubnetStateDeleting, DelegatedSubnetStateFailed, DelegatedSubnetStateProvisioning, DelegatedSubnetStateSucceeded} +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/models.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/models.go new file mode 100644 index 000000000000..b4ae0ae463e2 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/models.go @@ -0,0 +1,682 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork" + +// ControllerCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ControllerCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ControllerCreateFuture) Result(client ControllerClient) (dc DelegatedController, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("delegatednetwork.ControllerCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dc.Response.Response, err = future.GetResult(sender); err == nil && dc.Response.Response.StatusCode != http.StatusNoContent { + dc, err = client.CreateResponder(dc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerCreateFuture", "Result", dc.Response.Response, "Failure responding to request") + } + } + return +} + +// ControllerDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ControllerDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ControllerDeleteFuture) Result(client ControllerClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.ControllerDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("delegatednetwork.ControllerDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ControllerProperties properties of Delegated controller resource. +type ControllerProperties struct { + // State - READ-ONLY; The current state of dnc controller resource. Possible values include: 'Deleting', 'Succeeded', 'Failed', 'Provisioning' + State ControllerState `json:"state,omitempty"` + // Type - Type of dnc controller. + Type *string `json:"type,omitempty"` + // ResourceGUID - Gets or sets resource GUID property of the controller resource. + ResourceGUID *string `json:"resourceGuid,omitempty"` + // DncAppID - Get controller AAD ID. + DncAppID *string `json:"dncAppID,omitempty"` + // DncEndpoint - Dnc Endpoint url. + DncEndpoint *string `json:"dncEndpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for ControllerProperties. +func (cp ControllerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Type != nil { + objectMap["type"] = cp.Type + } + if cp.ResourceGUID != nil { + objectMap["resourceGuid"] = cp.ResourceGUID + } + if cp.DncAppID != nil { + objectMap["dncAppID"] = cp.DncAppID + } + if cp.DncEndpoint != nil { + objectMap["dncEndpoint"] = cp.DncEndpoint + } + return json.Marshal(objectMap) +} + +// ControllerResource represents an instance of an DNC controller resource. +type ControllerResource struct { + // ID - READ-ONLY; An identifier that represents the DNC controller resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the DNC controller resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the DNC controller resource.(Microsoft.DelegatedNetwork/controller) + Type *string `json:"type,omitempty"` + // Location - Location of the DNC controller resource. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ControllerResource. +func (cr ControllerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Location != nil { + objectMap["location"] = cr.Location + } + return json.Marshal(objectMap) +} + +// ControllerTypeParameters details of controller type. +type ControllerTypeParameters struct { + // ControllerType - Type of Delegated controller. + ControllerType *string `json:"controllerType,omitempty"` + // KubernetesProperties - properties of kubernetes clusters + KubernetesProperties *[]KubernetesProperties `json:"kubernetesProperties,omitempty"` +} + +// DelegatedController represents an instance of a DNC controller. +type DelegatedController struct { + autorest.Response `json:"-"` + // ControllerProperties - Properties of the provision operation request. + *ControllerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; An identifier that represents the DNC controller resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the DNC controller resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the DNC controller resource.(Microsoft.DelegatedNetwork/controller) + Type *string `json:"type,omitempty"` + // Location - Location of the DNC controller resource. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedController. +func (dc DelegatedController) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.ControllerProperties != nil { + objectMap["properties"] = dc.ControllerProperties + } + if dc.Location != nil { + objectMap["location"] = dc.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DelegatedController struct. +func (dc *DelegatedController) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var controllerProperties ControllerProperties + err = json.Unmarshal(*v, &controllerProperties) + if err != nil { + return err + } + dc.ControllerProperties = &controllerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dc.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dc.Location = &location + } + } + } + + return nil +} + +// DelegatedControllers an array of Delegated controller resources. +type DelegatedControllers struct { + autorest.Response `json:"-"` + // Value - An array of Delegated controller resources. + Value *[]DelegatedController `json:"value,omitempty"` +} + +// DelegatedSubnet delegated subnet details +type DelegatedSubnet struct { + autorest.Response `json:"-"` + // DelegatedSubnetProperties - Properties of the delegated subnet request + *DelegatedSubnetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; An identifier that represents the DelegatedSubnet resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the DelegatedSubnet resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the DelegatedSubnet resource.(Microsoft.DelegatedNetwork/delegatedSubnet) + Type *string `json:"type,omitempty"` + // Location - Location of the DelegatedSubnet resource. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedSubnet. +func (ds DelegatedSubnet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ds.DelegatedSubnetProperties != nil { + objectMap["properties"] = ds.DelegatedSubnetProperties + } + if ds.Location != nil { + objectMap["location"] = ds.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DelegatedSubnet struct. +func (ds *DelegatedSubnet) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var delegatedSubnetProperties DelegatedSubnetProperties + err = json.Unmarshal(*v, &delegatedSubnetProperties) + if err != nil { + return err + } + ds.DelegatedSubnetProperties = &delegatedSubnetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ds.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ds.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ds.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ds.Location = &location + } + } + } + + return nil +} + +// DelegatedSubnetList an array of Delegated subnets resources. +type DelegatedSubnetList struct { + autorest.Response `json:"-"` + // Value - An array of Delegated subnets resources. + Value *[]DelegatedSubnet `json:"value,omitempty"` +} + +// DelegatedSubnetParameters delegatedSubnet Parameters +type DelegatedSubnetParameters struct { + // ControllerID - Delegated Network Controller ID + ControllerID *string `json:"controllerID,omitempty"` +} + +// DelegatedSubnetProperties properties of delegated subnet resource. +type DelegatedSubnetProperties struct { + // State - READ-ONLY; The current state of delegated subnet resource. Possible values include: 'DelegatedSubnetStateDeleting', 'DelegatedSubnetStateSucceeded', 'DelegatedSubnetStateFailed', 'DelegatedSubnetStateProvisioning' + State DelegatedSubnetState `json:"state,omitempty"` +} + +// DelegatedSubnetResource represents an instance of a DelegatedSubnet resource. +type DelegatedSubnetResource struct { + // ID - READ-ONLY; An identifier that represents the DelegatedSubnet resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the DelegatedSubnet resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the DelegatedSubnet resource.(Microsoft.DelegatedNetwork/delegatedSubnet) + Type *string `json:"type,omitempty"` + // Location - Location of the DelegatedSubnet resource. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedSubnetResource. +func (dsr DelegatedSubnetResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsr.Location != nil { + objectMap["location"] = dsr.Location + } + return json.Marshal(objectMap) +} + +// DelegatedSubnetServiceDeleteDetailsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DelegatedSubnetServiceDeleteDetailsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DelegatedSubnetServiceDeleteDetailsFuture) Result(client DelegatedSubnetServiceClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServiceDeleteDetailsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("delegatednetwork.DelegatedSubnetServiceDeleteDetailsFuture") + return + } + ar.Response = future.Response() + return +} + +// DelegatedSubnetServicePatchDetailsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DelegatedSubnetServicePatchDetailsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DelegatedSubnetServicePatchDetailsFuture) Result(client DelegatedSubnetServiceClient) (ds DelegatedSubnet, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServicePatchDetailsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("delegatednetwork.DelegatedSubnetServicePatchDetailsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ds.Response.Response, err = future.GetResult(sender); err == nil && ds.Response.Response.StatusCode != http.StatusNoContent { + ds, err = client.PatchDetailsResponder(ds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServicePatchDetailsFuture", "Result", ds.Response.Response, "Failure responding to request") + } + } + return +} + +// DelegatedSubnetServicePutDetailsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DelegatedSubnetServicePutDetailsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DelegatedSubnetServicePutDetailsFuture) Result(client DelegatedSubnetServiceClient) (ds DelegatedSubnet, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServicePutDetailsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("delegatednetwork.DelegatedSubnetServicePutDetailsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ds.Response.Response, err = future.GetResult(sender); err == nil && ds.Response.Response.StatusCode != http.StatusNoContent { + ds, err = client.PutDetailsResponder(ds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.DelegatedSubnetServicePutDetailsFuture", "Result", ds.Response.Response, "Failure responding to request") + } + } + return +} + +// ErrorDefinition error definition. +type ErrorDefinition struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; Internal error details. + Details *[]ErrorDefinition `json:"details,omitempty"` +} + +// ErrorResponse error response. +type ErrorResponse struct { + // Error - Error description + Error *ErrorDefinition `json:"error,omitempty"` +} + +// KubernetesProperties properties of kubernetes cluster +type KubernetesProperties struct { + // ServerAppID - AAD ID used with apiserver + ServerAppID *string `json:"serverAppID,omitempty"` + // ServerTenantID - TenantID of server App ID + ServerTenantID *string `json:"serverTenantID,omitempty"` + // ClusterRootCA - RootCA certificate of kubernetes cluster + ClusterRootCA *string `json:"clusterRootCA,omitempty"` + // APIServerEndpoint - APIServer url + APIServerEndpoint *string `json:"apiServerEndpoint,omitempty"` +} + +// Operation microsoft.DelegatedNetwork REST API operation definition +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // IsDataAction - Gets or sets a value indicating whether the operation is a data action or not. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Operation properties display + Display *OperationDisplay `json:"display,omitempty"` + // Properties - Properties of the operation + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Origin != nil { + objectMap["origin"] = o.Origin + } + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.DelegatedNetwork. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed: controller, etc. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type: create, get, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Friendly description for the operation, + Description *string `json:"description,omitempty"` +} + +// OperationListResult result of request to list controller operations.It contains a list of operations and a +// URL link to get the next set of results +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations supported by the Microsoft.DelegatedNetwork resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if olr.NextLink != nil { + objectMap["nextLink"] = olr.NextLink + } + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/operations.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/operations.go new file mode 100644 index 000000000000..72b6b5172838 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/operations.go @@ -0,0 +1,149 @@ +package delegatednetwork + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the DNC web api provides way to create, get and delete dnc controller +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available DelegatedNetwork service REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "List", resp, "Failure responding to request") + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-08-08-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DelegatedNetwork/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "delegatednetwork.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/version.go b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/version.go new file mode 100644 index 000000000000..628b8c3797d1 --- /dev/null +++ b/services/preview/delegatednetwork/mgmt/2020-08-08-preview/delegatednetwork/version.go @@ -0,0 +1,30 @@ +package delegatednetwork + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " delegatednetwork/2020-08-08-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}