From 6b6cf3d1c91ea145e8344d47e307462915a0f7fb Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 17 Nov 2020 01:02:11 +0000 Subject: [PATCH] CodeGen from PR 11224 in Azure/azure-rest-api-specs Add WVD Scaling Plan resource definitions (#11224) Co-authored-by: Jeremy Hurren --- .../applicationgroups.go | 657 ++++ .../desktopvirtualization/applications.go | 554 +++ .../desktopvirtualization/client.go | 52 + .../desktopvirtualization/desktops.go | 323 ++ .../desktopvirtualizationapi/interfaces.go | 147 + .../desktopvirtualization/enums.go | 247 ++ .../desktopvirtualization/hostpools.go | 650 +++ .../desktopvirtualization/models.go | 3500 +++++++++++++++++ .../desktopvirtualization/msiximages.go | 175 + .../desktopvirtualization/msixpackages.go | 554 +++ .../desktopvirtualization/operations.go | 108 + .../desktopvirtualization/sessionhosts.go | 460 +++ .../desktopvirtualization/startmenuitems.go | 172 + .../desktopvirtualization/usersessions.go | 709 ++++ .../desktopvirtualization/version.go | 30 + .../desktopvirtualization/workspaces.go | 644 +++ 16 files changed, 8982 insertions(+) create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applicationgroups.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applications.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/client.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktops.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktopvirtualizationapi/interfaces.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/enums.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/hostpools.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/models.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msiximages.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msixpackages.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/operations.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/sessionhosts.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/startmenuitems.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/usersessions.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/version.go create mode 100644 services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/workspaces.go diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applicationgroups.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applicationgroups.go new file mode 100644 index 000000000000..54194497cf1d --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applicationgroups.go @@ -0,0 +1,657 @@ +package desktopvirtualization + +// 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" +) + +// ApplicationGroupsClient is the client for the ApplicationGroups methods of the Desktopvirtualization service. +type ApplicationGroupsClient struct { + BaseClient +} + +// NewApplicationGroupsClient creates an instance of the ApplicationGroupsClient client. +func NewApplicationGroupsClient(subscriptionID string) ApplicationGroupsClient { + return NewApplicationGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationGroupsClientWithBaseURI creates an instance of the ApplicationGroupsClient 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 NewApplicationGroupsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGroupsClient { + return ApplicationGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update an applicationGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationGroup - object containing ApplicationGroup definitions. +func (client ApplicationGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup ApplicationGroup) (result ApplicationGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: applicationGroup, + Constraints: []validation.Constraint{{Target: "applicationGroup.ApplicationGroupProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "applicationGroup.ApplicationGroupProperties.HostPoolArmPath", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationGroupName, applicationGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplicationGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup ApplicationGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}", pathParameters), + autorest.WithJSON(applicationGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplicationGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationGroup, 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 remove an applicationGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +func (client ApplicationGroupsClient) Delete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationGroupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, applicationGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}", 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 ApplicationGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an application group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +func (client ApplicationGroupsClient) Get(ctx context.Context, resourceGroupName string, applicationGroupName string) (result ApplicationGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationGroupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, applicationGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationGroupsClient) GetResponder(resp *http.Response) (result ApplicationGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list applicationGroups. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// filter - oData filter expression. Valid properties for filtering are applicationGroupType. +func (client ApplicationGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result ApplicationGroupListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.agl.Response.Response != nil { + sc = result.agl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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("desktopvirtualization.ApplicationGroupsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.agl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.agl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.agl.hasNextLink() && result.agl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ApplicationGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups", 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 ApplicationGroupsClient) 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 ApplicationGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ApplicationGroupsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationGroupList) (result ApplicationGroupList, err error) { + req, err := lastResults.applicationGroupListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationGroupsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result ApplicationGroupListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName, filter) + return +} + +// ListBySubscription list applicationGroups in subscription. +// Parameters: +// filter - oData filter expression. Valid properties for filtering are applicationGroupType. +func (client ApplicationGroupsClient) ListBySubscription(ctx context.Context, filter string) (result ApplicationGroupListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.ListBySubscription") + defer func() { + sc := -1 + if result.agl.Response.Response != nil { + sc = result.agl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationGroupsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.agl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.agl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.agl.hasNextLink() && result.agl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ApplicationGroupsClient) ListBySubscriptionPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups", 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 ApplicationGroupsClient) 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 ApplicationGroupsClient) ListBySubscriptionResponder(resp *http.Response) (result ApplicationGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ApplicationGroupsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ApplicationGroupList) (result ApplicationGroupList, err error) { + req, err := lastResults.applicationGroupListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationGroupsClient) ListBySubscriptionComplete(ctx context.Context, filter string) (result ApplicationGroupListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.ListBySubscription") + 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.ListBySubscription(ctx, filter) + return +} + +// Update update an applicationGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationGroup - object containing ApplicationGroup definitions. +func (client ApplicationGroupsClient) Update(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup *ApplicationGroupPatch) (result ApplicationGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupsClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationGroupsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGroupName, applicationGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationGroupsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ApplicationGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup *ApplicationGroupPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if applicationGroup != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(applicationGroup)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ApplicationGroupsClient) UpdateResponder(resp *http.Response) (result ApplicationGroup, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applications.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applications.go new file mode 100644 index 000000000000..ec3f8981b0f7 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/applications.go @@ -0,0 +1,554 @@ +package desktopvirtualization + +// 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" +) + +// ApplicationsClient is the client for the Applications methods of the Desktopvirtualization service. +type ApplicationsClient struct { + BaseClient +} + +// NewApplicationsClient creates an instance of the ApplicationsClient client. +func NewApplicationsClient(subscriptionID string) ApplicationsClient { + return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationsClientWithBaseURI creates an instance of the ApplicationsClient 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 NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient { + return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update an application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationName - the name of the application within the specified application group +// application - object containing Application definitions. +func (client ApplicationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application Application) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: application, + Constraints: []validation.Constraint{{Target: "application.ApplicationProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationGroupName, applicationName, application) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplicationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application Application) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", pathParameters), + autorest.WithJSON(application), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) CreateOrUpdateResponder(resp *http.Response) (result Application, 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 remove an application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationName - the name of the application within the specified application group +func (client ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, applicationGroupName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", 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 ApplicationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationName - the name of the application within the specified application group +func (client ApplicationsClient) Get(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, applicationGroupName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list applications. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +func (client ApplicationsClient) List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result ApplicationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, applicationGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "List", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ApplicationsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications", pathParameters), + 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 ApplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) ListResponder(resp *http.Response) (result ApplicationList, 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 ApplicationsClient) listNextResults(ctx context.Context, lastResults ApplicationList) (result ApplicationList, err error) { + req, err := lastResults.applicationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "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, "desktopvirtualization.ApplicationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationsClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result ApplicationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.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, resourceGroupName, applicationGroupName) + return +} + +// Update update an application. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// applicationName - the name of the application within the specified application group +// application - object containing Application definitions. +func (client ApplicationsClient) Update(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application *ApplicationPatch) (result Application, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationsClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: applicationName, + Constraints: []validation.Constraint{{Target: "applicationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.ApplicationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGroupName, applicationName, application) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.ApplicationsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ApplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application *ApplicationPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "applicationName": autorest.Encode("path", applicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if application != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(application)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) UpdateResponder(resp *http.Response) (result Application, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/client.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/client.go new file mode 100644 index 000000000000..c0946e4098af --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/client.go @@ -0,0 +1,52 @@ +// Package desktopvirtualization implements the Azure ARM Desktopvirtualization service API version 2020-10-19-preview. +// +// +package desktopvirtualization + +// 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 Desktopvirtualization + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Desktopvirtualization. +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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktops.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktops.go new file mode 100644 index 000000000000..0d7a1a91f5db --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktops.go @@ -0,0 +1,323 @@ +package desktopvirtualization + +// 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" +) + +// DesktopsClient is the client for the Desktops methods of the Desktopvirtualization service. +type DesktopsClient struct { + BaseClient +} + +// NewDesktopsClient creates an instance of the DesktopsClient client. +func NewDesktopsClient(subscriptionID string) DesktopsClient { + return NewDesktopsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDesktopsClientWithBaseURI creates an instance of the DesktopsClient 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 NewDesktopsClientWithBaseURI(baseURI string, subscriptionID string) DesktopsClient { + return DesktopsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get a desktop. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// desktopName - the name of the desktop within the specified desktop group +func (client DesktopsClient) Get(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string) (result Desktop, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DesktopsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: desktopName, + Constraints: []validation.Constraint{{Target: "desktopName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "desktopName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.DesktopsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, applicationGroupName, desktopName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DesktopsClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "desktopName": autorest.Encode("path", desktopName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DesktopsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DesktopsClient) GetResponder(resp *http.Response) (result Desktop, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list desktops. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +func (client DesktopsClient) List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result DesktopList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DesktopsClient.List") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.DesktopsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, applicationGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DesktopsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops", pathParameters), + 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 DesktopsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DesktopsClient) ListResponder(resp *http.Response) (result DesktopList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a desktop. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +// desktopName - the name of the desktop within the specified desktop group +// desktop - object containing Desktop definitions. +func (client DesktopsClient) Update(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string, desktop *DesktopPatch) (result Desktop, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DesktopsClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: desktopName, + Constraints: []validation.Constraint{{Target: "desktopName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "desktopName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.DesktopsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, applicationGroupName, desktopName, desktop) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.DesktopsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DesktopsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string, desktop *DesktopPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "desktopName": autorest.Encode("path", desktopName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if desktop != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(desktop)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DesktopsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DesktopsClient) UpdateResponder(resp *http.Response) (result Desktop, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktopvirtualizationapi/interfaces.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktopvirtualizationapi/interfaces.go new file mode 100644 index 000000000000..7c435c214f7f --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/desktopvirtualizationapi/interfaces.go @@ -0,0 +1,147 @@ +package desktopvirtualizationapi + +// 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result desktopvirtualization.ResourceProviderOperationList, err error) +} + +var _ OperationsClientAPI = (*desktopvirtualization.OperationsClient)(nil) + +// WorkspacesClientAPI contains the set of methods on the WorkspacesClient type. +type WorkspacesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, workspace desktopvirtualization.Workspace) (result desktopvirtualization.Workspace, err error) + Delete(ctx context.Context, resourceGroupName string, workspaceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, workspaceName string) (result desktopvirtualization.Workspace, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result desktopvirtualization.WorkspaceListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result desktopvirtualization.WorkspaceListIterator, err error) + ListBySubscription(ctx context.Context) (result desktopvirtualization.WorkspaceListPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result desktopvirtualization.WorkspaceListIterator, err error) + Update(ctx context.Context, resourceGroupName string, workspaceName string, workspace *desktopvirtualization.WorkspacePatch) (result desktopvirtualization.Workspace, err error) +} + +var _ WorkspacesClientAPI = (*desktopvirtualization.WorkspacesClient)(nil) + +// ApplicationGroupsClientAPI contains the set of methods on the ApplicationGroupsClient type. +type ApplicationGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup desktopvirtualization.ApplicationGroup) (result desktopvirtualization.ApplicationGroup, err error) + Delete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.ApplicationGroup, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result desktopvirtualization.ApplicationGroupListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result desktopvirtualization.ApplicationGroupListIterator, err error) + ListBySubscription(ctx context.Context, filter string) (result desktopvirtualization.ApplicationGroupListPage, err error) + ListBySubscriptionComplete(ctx context.Context, filter string) (result desktopvirtualization.ApplicationGroupListIterator, err error) + Update(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationGroup *desktopvirtualization.ApplicationGroupPatch) (result desktopvirtualization.ApplicationGroup, err error) +} + +var _ ApplicationGroupsClientAPI = (*desktopvirtualization.ApplicationGroupsClient)(nil) + +// StartMenuItemsClientAPI contains the set of methods on the StartMenuItemsClient type. +type StartMenuItemsClientAPI interface { + List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.StartMenuItemListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.StartMenuItemListIterator, err error) +} + +var _ StartMenuItemsClientAPI = (*desktopvirtualization.StartMenuItemsClient)(nil) + +// ApplicationsClientAPI contains the set of methods on the ApplicationsClient type. +type ApplicationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application desktopvirtualization.Application) (result desktopvirtualization.Application, err error) + Delete(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string) (result desktopvirtualization.Application, err error) + List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.ApplicationListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.ApplicationListIterator, err error) + Update(ctx context.Context, resourceGroupName string, applicationGroupName string, applicationName string, application *desktopvirtualization.ApplicationPatch) (result desktopvirtualization.Application, err error) +} + +var _ ApplicationsClientAPI = (*desktopvirtualization.ApplicationsClient)(nil) + +// DesktopsClientAPI contains the set of methods on the DesktopsClient type. +type DesktopsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string) (result desktopvirtualization.Desktop, err error) + List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result desktopvirtualization.DesktopList, err error) + Update(ctx context.Context, resourceGroupName string, applicationGroupName string, desktopName string, desktop *desktopvirtualization.DesktopPatch) (result desktopvirtualization.Desktop, err error) +} + +var _ DesktopsClientAPI = (*desktopvirtualization.DesktopsClient)(nil) + +// HostPoolsClientAPI contains the set of methods on the HostPoolsClient type. +type HostPoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool desktopvirtualization.HostPool) (result desktopvirtualization.HostPool, err error) + Delete(ctx context.Context, resourceGroupName string, hostPoolName string, force *bool) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, hostPoolName string) (result desktopvirtualization.HostPool, err error) + List(ctx context.Context) (result desktopvirtualization.HostPoolListPage, err error) + ListComplete(ctx context.Context) (result desktopvirtualization.HostPoolListIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result desktopvirtualization.HostPoolListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result desktopvirtualization.HostPoolListIterator, err error) + Update(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool *desktopvirtualization.HostPoolPatch) (result desktopvirtualization.HostPool, err error) +} + +var _ HostPoolsClientAPI = (*desktopvirtualization.HostPoolsClient)(nil) + +// UserSessionsClientAPI contains the set of methods on the UserSessionsClient type. +type UserSessionsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, force *bool) (result autorest.Response, err error) + Disconnect(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (result desktopvirtualization.UserSession, err error) + List(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result desktopvirtualization.UserSessionListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result desktopvirtualization.UserSessionListIterator, err error) + ListByHostPool(ctx context.Context, resourceGroupName string, hostPoolName string, filter string) (result desktopvirtualization.UserSessionListPage, err error) + ListByHostPoolComplete(ctx context.Context, resourceGroupName string, hostPoolName string, filter string) (result desktopvirtualization.UserSessionListIterator, err error) + SendMessageMethod(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, sendMessage *desktopvirtualization.SendMessage) (result autorest.Response, err error) +} + +var _ UserSessionsClientAPI = (*desktopvirtualization.UserSessionsClient)(nil) + +// SessionHostsClientAPI contains the set of methods on the SessionHostsClient type. +type SessionHostsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, force *bool) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result desktopvirtualization.SessionHost, err error) + List(ctx context.Context, resourceGroupName string, hostPoolName string) (result desktopvirtualization.SessionHostListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string) (result desktopvirtualization.SessionHostListIterator, err error) + Update(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, sessionHost *desktopvirtualization.SessionHostPatch) (result desktopvirtualization.SessionHost, err error) +} + +var _ SessionHostsClientAPI = (*desktopvirtualization.SessionHostsClient)(nil) + +// MSIXPackagesClientAPI contains the set of methods on the MSIXPackagesClient type. +type MSIXPackagesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage desktopvirtualization.MSIXPackage) (result desktopvirtualization.MSIXPackage, err error) + Delete(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (result desktopvirtualization.MSIXPackage, err error) + List(ctx context.Context, resourceGroupName string, hostPoolName string) (result desktopvirtualization.MSIXPackageListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string) (result desktopvirtualization.MSIXPackageListIterator, err error) + Update(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage *desktopvirtualization.MSIXPackagePatch) (result desktopvirtualization.MSIXPackage, err error) +} + +var _ MSIXPackagesClientAPI = (*desktopvirtualization.MSIXPackagesClient)(nil) + +// MsixImagesClientAPI contains the set of methods on the MsixImagesClient type. +type MsixImagesClientAPI interface { + Expand(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI desktopvirtualization.MSIXImageURI) (result desktopvirtualization.ExpandMsixImageListPage, err error) + ExpandComplete(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI desktopvirtualization.MSIXImageURI) (result desktopvirtualization.ExpandMsixImageListIterator, err error) +} + +var _ MsixImagesClientAPI = (*desktopvirtualization.MsixImagesClient)(nil) diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/enums.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/enums.go new file mode 100644 index 000000000000..32ca33b1844b --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/enums.go @@ -0,0 +1,247 @@ +package desktopvirtualization + +// 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. + +// ApplicationGroupType enumerates the values for application group type. +type ApplicationGroupType string + +const ( + // ApplicationGroupTypeDesktop ... + ApplicationGroupTypeDesktop ApplicationGroupType = "Desktop" + // ApplicationGroupTypeRemoteApp ... + ApplicationGroupTypeRemoteApp ApplicationGroupType = "RemoteApp" +) + +// PossibleApplicationGroupTypeValues returns an array of possible values for the ApplicationGroupType const type. +func PossibleApplicationGroupTypeValues() []ApplicationGroupType { + return []ApplicationGroupType{ApplicationGroupTypeDesktop, ApplicationGroupTypeRemoteApp} +} + +// ApplicationType enumerates the values for application type. +type ApplicationType string + +const ( + // ApplicationTypeDesktop ... + ApplicationTypeDesktop ApplicationType = "Desktop" + // ApplicationTypeRemoteApp ... + ApplicationTypeRemoteApp ApplicationType = "RemoteApp" +) + +// PossibleApplicationTypeValues returns an array of possible values for the ApplicationType const type. +func PossibleApplicationTypeValues() []ApplicationType { + return []ApplicationType{ApplicationTypeDesktop, ApplicationTypeRemoteApp} +} + +// CommandLineSetting enumerates the values for command line setting. +type CommandLineSetting string + +const ( + // Allow ... + Allow CommandLineSetting = "Allow" + // DoNotAllow ... + DoNotAllow CommandLineSetting = "DoNotAllow" + // Require ... + Require CommandLineSetting = "Require" +) + +// PossibleCommandLineSettingValues returns an array of possible values for the CommandLineSetting const type. +func PossibleCommandLineSettingValues() []CommandLineSetting { + return []CommandLineSetting{Allow, DoNotAllow, Require} +} + +// HostPoolType enumerates the values for host pool type. +type HostPoolType string + +const ( + // Personal ... + Personal HostPoolType = "Personal" + // Pooled ... + Pooled HostPoolType = "Pooled" +) + +// PossibleHostPoolTypeValues returns an array of possible values for the HostPoolType const type. +func PossibleHostPoolTypeValues() []HostPoolType { + return []HostPoolType{Personal, Pooled} +} + +// LoadBalancerType enumerates the values for load balancer type. +type LoadBalancerType string + +const ( + // BreadthFirst ... + BreadthFirst LoadBalancerType = "BreadthFirst" + // DepthFirst ... + DepthFirst LoadBalancerType = "DepthFirst" + // Persistent ... + Persistent LoadBalancerType = "Persistent" +) + +// PossibleLoadBalancerTypeValues returns an array of possible values for the LoadBalancerType const type. +func PossibleLoadBalancerTypeValues() []LoadBalancerType { + return []LoadBalancerType{BreadthFirst, DepthFirst, Persistent} +} + +// PersonalDesktopAssignmentType enumerates the values for personal desktop assignment type. +type PersonalDesktopAssignmentType string + +const ( + // Automatic ... + Automatic PersonalDesktopAssignmentType = "Automatic" + // Direct ... + Direct PersonalDesktopAssignmentType = "Direct" +) + +// PossiblePersonalDesktopAssignmentTypeValues returns an array of possible values for the PersonalDesktopAssignmentType const type. +func PossiblePersonalDesktopAssignmentTypeValues() []PersonalDesktopAssignmentType { + return []PersonalDesktopAssignmentType{Automatic, Direct} +} + +// PreferredAppGroupType enumerates the values for preferred app group type. +type PreferredAppGroupType string + +const ( + // PreferredAppGroupTypeDesktop ... + PreferredAppGroupTypeDesktop PreferredAppGroupType = "Desktop" + // PreferredAppGroupTypeNone ... + PreferredAppGroupTypeNone PreferredAppGroupType = "None" + // PreferredAppGroupTypeRailApplications ... + PreferredAppGroupTypeRailApplications PreferredAppGroupType = "RailApplications" +) + +// PossiblePreferredAppGroupTypeValues returns an array of possible values for the PreferredAppGroupType const type. +func PossiblePreferredAppGroupTypeValues() []PreferredAppGroupType { + return []PreferredAppGroupType{PreferredAppGroupTypeDesktop, PreferredAppGroupTypeNone, PreferredAppGroupTypeRailApplications} +} + +// RegistrationTokenOperation enumerates the values for registration token operation. +type RegistrationTokenOperation string + +const ( + // Delete ... + Delete RegistrationTokenOperation = "Delete" + // None ... + None RegistrationTokenOperation = "None" + // Update ... + Update RegistrationTokenOperation = "Update" +) + +// PossibleRegistrationTokenOperationValues returns an array of possible values for the RegistrationTokenOperation const type. +func PossibleRegistrationTokenOperationValues() []RegistrationTokenOperation { + return []RegistrationTokenOperation{Delete, None, Update} +} + +// RemoteApplicationType enumerates the values for remote application type. +type RemoteApplicationType string + +const ( + // InBuilt ... + InBuilt RemoteApplicationType = "InBuilt" + // MsixApplication ... + MsixApplication RemoteApplicationType = "MsixApplication" +) + +// PossibleRemoteApplicationTypeValues returns an array of possible values for the RemoteApplicationType const type. +func PossibleRemoteApplicationTypeValues() []RemoteApplicationType { + return []RemoteApplicationType{InBuilt, MsixApplication} +} + +// SessionState enumerates the values for session state. +type SessionState string + +const ( + // Active ... + Active SessionState = "Active" + // Disconnected ... + Disconnected SessionState = "Disconnected" + // LogOff ... + LogOff SessionState = "LogOff" + // Pending ... + Pending SessionState = "Pending" + // Unknown ... + Unknown SessionState = "Unknown" + // UserProfileDiskMounted ... + UserProfileDiskMounted SessionState = "UserProfileDiskMounted" +) + +// PossibleSessionStateValues returns an array of possible values for the SessionState const type. +func PossibleSessionStateValues() []SessionState { + return []SessionState{Active, Disconnected, LogOff, Pending, Unknown, UserProfileDiskMounted} +} + +// SSOSecretType enumerates the values for sso secret type. +type SSOSecretType string + +const ( + // Certificate ... + Certificate SSOSecretType = "Certificate" + // CertificateInKeyVault ... + CertificateInKeyVault SSOSecretType = "CertificateInKeyVault" + // SharedKey ... + SharedKey SSOSecretType = "SharedKey" + // SharedKeyInKeyVault ... + SharedKeyInKeyVault SSOSecretType = "SharedKeyInKeyVault" +) + +// PossibleSSOSecretTypeValues returns an array of possible values for the SSOSecretType const type. +func PossibleSSOSecretTypeValues() []SSOSecretType { + return []SSOSecretType{Certificate, CertificateInKeyVault, SharedKey, SharedKeyInKeyVault} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusAvailable ... + StatusAvailable Status = "Available" + // StatusDisconnected ... + StatusDisconnected Status = "Disconnected" + // StatusShutdown ... + StatusShutdown Status = "Shutdown" + // StatusUnavailable ... + StatusUnavailable Status = "Unavailable" + // StatusUpgradeFailed ... + StatusUpgradeFailed Status = "UpgradeFailed" + // StatusUpgrading ... + StatusUpgrading Status = "Upgrading" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusAvailable, StatusDisconnected, StatusShutdown, StatusUnavailable, StatusUpgradeFailed, StatusUpgrading} +} + +// UpdateState enumerates the values for update state. +type UpdateState string + +const ( + // UpdateStateFailed ... + UpdateStateFailed UpdateState = "Failed" + // UpdateStateInitial ... + UpdateStateInitial UpdateState = "Initial" + // UpdateStatePending ... + UpdateStatePending UpdateState = "Pending" + // UpdateStateStarted ... + UpdateStateStarted UpdateState = "Started" + // UpdateStateSucceeded ... + UpdateStateSucceeded UpdateState = "Succeeded" +) + +// PossibleUpdateStateValues returns an array of possible values for the UpdateState const type. +func PossibleUpdateStateValues() []UpdateState { + return []UpdateState{UpdateStateFailed, UpdateStateInitial, UpdateStatePending, UpdateStateStarted, UpdateStateSucceeded} +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/hostpools.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/hostpools.go new file mode 100644 index 000000000000..383fd3c4af4b --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/hostpools.go @@ -0,0 +1,650 @@ +package desktopvirtualization + +// 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" +) + +// HostPoolsClient is the client for the HostPools methods of the Desktopvirtualization service. +type HostPoolsClient struct { + BaseClient +} + +// NewHostPoolsClient creates an instance of the HostPoolsClient client. +func NewHostPoolsClient(subscriptionID string) HostPoolsClient { + return NewHostPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHostPoolsClientWithBaseURI creates an instance of the HostPoolsClient 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 NewHostPoolsClientWithBaseURI(baseURI string, subscriptionID string) HostPoolsClient { + return HostPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a host pool. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// hostPool - object containing HostPool definitions. +func (client HostPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool HostPool) (result HostPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: hostPool, + Constraints: []validation.Constraint{{Target: "hostPool.HostPoolProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.HostPoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, hostPoolName, hostPool) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client HostPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool HostPool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}", pathParameters), + autorest.WithJSON(hostPool), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client HostPoolsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client HostPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result HostPool, 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 remove a host pool. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// force - force flag to delete sessionHost. +func (client HostPoolsClient) Delete(ctx context.Context, resourceGroupName string, hostPoolName string, force *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.HostPoolsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, hostPoolName, force) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HostPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, force *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if force != nil { + queryParameters["force"] = autorest.Encode("query", *force) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}", 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 HostPoolsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HostPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a host pool. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +func (client HostPoolsClient) Get(ctx context.Context, resourceGroupName string, hostPoolName string) (result HostPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.HostPoolsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, hostPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HostPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, hostPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HostPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HostPoolsClient) GetResponder(resp *http.Response) (result HostPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list hostPools in subscription. +func (client HostPoolsClient) List(ctx context.Context) (result HostPoolListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.List") + defer func() { + sc := -1 + if result.hpl.Response.Response != nil { + sc = result.hpl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.HostPoolsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.hpl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "List", resp, "Failure sending request") + return + } + + result.hpl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "List", resp, "Failure responding to request") + } + if result.hpl.hasNextLink() && result.hpl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client HostPoolsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools", pathParameters), + 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 HostPoolsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client HostPoolsClient) ListResponder(resp *http.Response) (result HostPoolList, 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 HostPoolsClient) listNextResults(ctx context.Context, lastResults HostPoolList) (result HostPoolList, err error) { + req, err := lastResults.hostPoolListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "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, "desktopvirtualization.HostPoolsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client HostPoolsClient) ListComplete(ctx context.Context) (result HostPoolListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.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 +} + +// ListByResourceGroup list hostPools. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client HostPoolsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result HostPoolListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.hpl.Response.Response != nil { + sc = result.hpl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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("desktopvirtualization.HostPoolsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.hpl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.hpl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.hpl.hasNextLink() && result.hpl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client HostPoolsClient) 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-10-19-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.DesktopVirtualization/hostPools", 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 HostPoolsClient) 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 HostPoolsClient) ListByResourceGroupResponder(resp *http.Response) (result HostPoolList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client HostPoolsClient) listByResourceGroupNextResults(ctx context.Context, lastResults HostPoolList) (result HostPoolList, err error) { + req, err := lastResults.hostPoolListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client HostPoolsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result HostPoolListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update a host pool. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// hostPool - object containing HostPool definitions. +func (client HostPoolsClient) Update(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool *HostPoolPatch) (result HostPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolsClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.HostPoolsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, hostPoolName, hostPool) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.HostPoolsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HostPoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, hostPool *HostPoolPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if hostPool != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(hostPool)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client HostPoolsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HostPoolsClient) UpdateResponder(resp *http.Response) (result HostPool, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/models.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/models.go new file mode 100644 index 000000000000..c4f13775d755 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/models.go @@ -0,0 +1,3500 @@ +package desktopvirtualization + +// 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/date" + "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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization" + +// Application schema for Application properties. +type Application struct { + autorest.Response `json:"-"` + // ApplicationProperties - Detailed properties for Application + *ApplicationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Application. +func (a Application) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.ApplicationProperties != nil { + objectMap["properties"] = a.ApplicationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Application struct. +func (a *Application) 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 applicationProperties ApplicationProperties + err = json.Unmarshal(*v, &applicationProperties) + if err != nil { + return err + } + a.ApplicationProperties = &applicationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// ApplicationGroup represents a ApplicationGroup definition. +type ApplicationGroup struct { + autorest.Response `json:"-"` + // ApplicationGroupProperties - Detailed properties for ApplicationGroup + *ApplicationGroupProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationGroup. +func (ag ApplicationGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ag.ApplicationGroupProperties != nil { + objectMap["properties"] = ag.ApplicationGroupProperties + } + if ag.Tags != nil { + objectMap["tags"] = ag.Tags + } + if ag.Location != nil { + objectMap["location"] = ag.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationGroup struct. +func (ag *ApplicationGroup) 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 applicationGroupProperties ApplicationGroupProperties + err = json.Unmarshal(*v, &applicationGroupProperties) + if err != nil { + return err + } + ag.ApplicationGroupProperties = &applicationGroupProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ag.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ag.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ag.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ag.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ag.Type = &typeVar + } + } + } + + return nil +} + +// ApplicationGroupList list of ApplicationGroup definitions. +type ApplicationGroupList struct { + autorest.Response `json:"-"` + // Value - List of ApplicationGroup definitions. + Value *[]ApplicationGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationGroupList. +func (agl ApplicationGroupList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agl.Value != nil { + objectMap["value"] = agl.Value + } + return json.Marshal(objectMap) +} + +// ApplicationGroupListIterator provides access to a complete listing of ApplicationGroup values. +type ApplicationGroupListIterator struct { + i int + page ApplicationGroupListPage +} + +// 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 *ApplicationGroupListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupListIterator.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 *ApplicationGroupListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationGroupListIterator) 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 ApplicationGroupListIterator) Response() ApplicationGroupList { + 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 ApplicationGroupListIterator) Value() ApplicationGroup { + if !iter.page.NotDone() { + return ApplicationGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationGroupListIterator type. +func NewApplicationGroupListIterator(page ApplicationGroupListPage) ApplicationGroupListIterator { + return ApplicationGroupListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (agl ApplicationGroupList) IsEmpty() bool { + return agl.Value == nil || len(*agl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (agl ApplicationGroupList) hasNextLink() bool { + return agl.NextLink != nil && len(*agl.NextLink) != 0 +} + +// applicationGroupListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (agl ApplicationGroupList) applicationGroupListPreparer(ctx context.Context) (*http.Request, error) { + if !agl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(agl.NextLink))) +} + +// ApplicationGroupListPage contains a page of ApplicationGroup values. +type ApplicationGroupListPage struct { + fn func(context.Context, ApplicationGroupList) (ApplicationGroupList, error) + agl ApplicationGroupList +} + +// 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 *ApplicationGroupListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGroupListPage.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.agl) + if err != nil { + return err + } + page.agl = 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 *ApplicationGroupListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationGroupListPage) NotDone() bool { + return !page.agl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationGroupListPage) Response() ApplicationGroupList { + return page.agl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationGroupListPage) Values() []ApplicationGroup { + if page.agl.IsEmpty() { + return nil + } + return *page.agl.Value +} + +// Creates a new instance of the ApplicationGroupListPage type. +func NewApplicationGroupListPage(cur ApplicationGroupList, getNextPage func(context.Context, ApplicationGroupList) (ApplicationGroupList, error)) ApplicationGroupListPage { + return ApplicationGroupListPage{ + fn: getNextPage, + agl: cur, + } +} + +// ApplicationGroupPatch applicationGroup properties that can be patched. +type ApplicationGroupPatch struct { + // Tags - tags to be updated + Tags map[string]*string `json:"tags"` + // ApplicationGroupPatchProperties - ApplicationGroup properties that can be patched. + *ApplicationGroupPatchProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationGroupPatch. +func (agp ApplicationGroupPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agp.Tags != nil { + objectMap["tags"] = agp.Tags + } + if agp.ApplicationGroupPatchProperties != nil { + objectMap["properties"] = agp.ApplicationGroupPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationGroupPatch struct. +func (agp *ApplicationGroupPatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + agp.Tags = tags + } + case "properties": + if v != nil { + var applicationGroupPatchProperties ApplicationGroupPatchProperties + err = json.Unmarshal(*v, &applicationGroupPatchProperties) + if err != nil { + return err + } + agp.ApplicationGroupPatchProperties = &applicationGroupPatchProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + agp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + agp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + agp.Type = &typeVar + } + } + } + + return nil +} + +// ApplicationGroupPatchProperties applicationGroup properties that can be patched. +type ApplicationGroupPatchProperties struct { + // Description - Description of ApplicationGroup. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of ApplicationGroup. + FriendlyName *string `json:"friendlyName,omitempty"` +} + +// ApplicationGroupProperties schema for ApplicationGroup properties. +type ApplicationGroupProperties struct { + // Description - Description of ApplicationGroup. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of ApplicationGroup. + FriendlyName *string `json:"friendlyName,omitempty"` + // HostPoolArmPath - HostPool arm path of ApplicationGroup. + HostPoolArmPath *string `json:"hostPoolArmPath,omitempty"` + // WorkspaceArmPath - READ-ONLY; Workspace arm path of ApplicationGroup. + WorkspaceArmPath *string `json:"workspaceArmPath,omitempty"` + // ApplicationGroupType - Resource Type of ApplicationGroup. Possible values include: 'ApplicationGroupTypeRemoteApp', 'ApplicationGroupTypeDesktop' + ApplicationGroupType ApplicationGroupType `json:"applicationGroupType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationGroupProperties. +func (agp ApplicationGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agp.Description != nil { + objectMap["description"] = agp.Description + } + if agp.FriendlyName != nil { + objectMap["friendlyName"] = agp.FriendlyName + } + if agp.HostPoolArmPath != nil { + objectMap["hostPoolArmPath"] = agp.HostPoolArmPath + } + if agp.ApplicationGroupType != "" { + objectMap["applicationGroupType"] = agp.ApplicationGroupType + } + return json.Marshal(objectMap) +} + +// ApplicationList list of Application definitions. +type ApplicationList struct { + autorest.Response `json:"-"` + // Value - List of Application definitions. + Value *[]Application `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationList. +func (al ApplicationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if al.Value != nil { + objectMap["value"] = al.Value + } + return json.Marshal(objectMap) +} + +// ApplicationListIterator provides access to a complete listing of Application values. +type ApplicationListIterator struct { + i int + page ApplicationListPage +} + +// 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 *ApplicationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListIterator.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 *ApplicationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationListIterator) 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 ApplicationListIterator) Response() ApplicationList { + 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 ApplicationListIterator) Value() Application { + if !iter.page.NotDone() { + return Application{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationListIterator type. +func NewApplicationListIterator(page ApplicationListPage) ApplicationListIterator { + return ApplicationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al ApplicationList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al ApplicationList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// applicationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al ApplicationList) applicationListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// ApplicationListPage contains a page of Application values. +type ApplicationListPage struct { + fn func(context.Context, ApplicationList) (ApplicationList, error) + al ApplicationList +} + +// 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 *ApplicationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationListPage.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.al) + if err != nil { + return err + } + page.al = 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 *ApplicationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationListPage) Response() ApplicationList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationListPage) Values() []Application { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the ApplicationListPage type. +func NewApplicationListPage(cur ApplicationList, getNextPage func(context.Context, ApplicationList) (ApplicationList, error)) ApplicationListPage { + return ApplicationListPage{ + fn: getNextPage, + al: cur, + } +} + +// ApplicationPatch application properties that can be patched. +type ApplicationPatch struct { + // Tags - tags to be updated + Tags map[string]*string `json:"tags"` + // ApplicationPatchProperties - Detailed properties for Application + *ApplicationPatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationPatch. +func (ap ApplicationPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.Tags != nil { + objectMap["tags"] = ap.Tags + } + if ap.ApplicationPatchProperties != nil { + objectMap["properties"] = ap.ApplicationPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationPatch struct. +func (ap *ApplicationPatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ap.Tags = tags + } + case "properties": + if v != nil { + var applicationPatchProperties ApplicationPatchProperties + err = json.Unmarshal(*v, &applicationPatchProperties) + if err != nil { + return err + } + ap.ApplicationPatchProperties = &applicationPatchProperties + } + } + } + + return nil +} + +// ApplicationPatchProperties application properties that can be patched. +type ApplicationPatchProperties struct { + // Description - Description of Application. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Application. + FriendlyName *string `json:"friendlyName,omitempty"` + // FilePath - Specifies a path for the executable file for the application. + FilePath *string `json:"filePath,omitempty"` + // CommandLineSetting - Specifies whether this published application can be launched with command line arguments provided by the client, command line arguments specified at publish time, or no command line arguments at all. Possible values include: 'DoNotAllow', 'Allow', 'Require' + CommandLineSetting CommandLineSetting `json:"commandLineSetting,omitempty"` + // CommandLineArguments - Command Line Arguments for Application. + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + // ShowInPortal - Specifies whether to show the RemoteApp program in the RD Web Access server. + ShowInPortal *bool `json:"showInPortal,omitempty"` + // IconPath - Path to icon. + IconPath *string `json:"iconPath,omitempty"` + // IconIndex - Index of the icon. + IconIndex *int32 `json:"iconIndex,omitempty"` + // MsixPackageFamilyName - Specifies the package family name for MSIX applications + MsixPackageFamilyName *string `json:"msixPackageFamilyName,omitempty"` + // MsixPackageApplicationID - Specifies the package application Id for MSIX applications + MsixPackageApplicationID *string `json:"msixPackageApplicationId,omitempty"` + // ApplicationType - Resource Type of Application. Possible values include: 'InBuilt', 'MsixApplication' + ApplicationType RemoteApplicationType `json:"applicationType,omitempty"` +} + +// ApplicationProperties schema for Application properties. +type ApplicationProperties struct { + // Description - Description of Application. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Application. + FriendlyName *string `json:"friendlyName,omitempty"` + // FilePath - Specifies a path for the executable file for the application. + FilePath *string `json:"filePath,omitempty"` + // MsixPackageFamilyName - Specifies the package family name for MSIX applications + MsixPackageFamilyName *string `json:"msixPackageFamilyName,omitempty"` + // MsixPackageApplicationID - Specifies the package application Id for MSIX applications + MsixPackageApplicationID *string `json:"msixPackageApplicationId,omitempty"` + // ApplicationType - Resource Type of Application. Possible values include: 'InBuilt', 'MsixApplication' + ApplicationType RemoteApplicationType `json:"applicationType,omitempty"` + // CommandLineSetting - Specifies whether this published application can be launched with command line arguments provided by the client, command line arguments specified at publish time, or no command line arguments at all. Possible values include: 'DoNotAllow', 'Allow', 'Require' + CommandLineSetting CommandLineSetting `json:"commandLineSetting,omitempty"` + // CommandLineArguments - Command Line Arguments for Application. + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + // ShowInPortal - Specifies whether to show the RemoteApp program in the RD Web Access server. + ShowInPortal *bool `json:"showInPortal,omitempty"` + // IconPath - Path to icon. + IconPath *string `json:"iconPath,omitempty"` + // IconIndex - Index of the icon. + IconIndex *int32 `json:"iconIndex,omitempty"` + // IconHash - READ-ONLY; Hash of the icon. + IconHash *string `json:"iconHash,omitempty"` + // IconContent - READ-ONLY; the icon a 64 bit string as a byte array. + IconContent *[]byte `json:"iconContent,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationProperties. +func (ap ApplicationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.Description != nil { + objectMap["description"] = ap.Description + } + if ap.FriendlyName != nil { + objectMap["friendlyName"] = ap.FriendlyName + } + if ap.FilePath != nil { + objectMap["filePath"] = ap.FilePath + } + if ap.MsixPackageFamilyName != nil { + objectMap["msixPackageFamilyName"] = ap.MsixPackageFamilyName + } + if ap.MsixPackageApplicationID != nil { + objectMap["msixPackageApplicationId"] = ap.MsixPackageApplicationID + } + if ap.ApplicationType != "" { + objectMap["applicationType"] = ap.ApplicationType + } + if ap.CommandLineSetting != "" { + objectMap["commandLineSetting"] = ap.CommandLineSetting + } + if ap.CommandLineArguments != nil { + objectMap["commandLineArguments"] = ap.CommandLineArguments + } + if ap.ShowInPortal != nil { + objectMap["showInPortal"] = ap.ShowInPortal + } + if ap.IconPath != nil { + objectMap["iconPath"] = ap.IconPath + } + if ap.IconIndex != nil { + objectMap["iconIndex"] = ap.IconIndex + } + return json.Marshal(objectMap) +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// CloudError ... +type CloudError struct { + Error *CloudErrorProperties `json:"error,omitempty"` +} + +// CloudErrorProperties ... +type CloudErrorProperties struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// Desktop schema for Desktop properties. +type Desktop struct { + autorest.Response `json:"-"` + // DesktopProperties - Detailed properties for Desktop + *DesktopProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Desktop. +func (d Desktop) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DesktopProperties != nil { + objectMap["properties"] = d.DesktopProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Desktop struct. +func (d *Desktop) 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 desktopProperties DesktopProperties + err = json.Unmarshal(*v, &desktopProperties) + if err != nil { + return err + } + d.DesktopProperties = &desktopProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DesktopList list of Desktop definitions. +type DesktopList struct { + autorest.Response `json:"-"` + // Value - List of Desktop definitions. + Value *[]Desktop `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DesktopList. +func (dl DesktopList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dl.Value != nil { + objectMap["value"] = dl.Value + } + return json.Marshal(objectMap) +} + +// DesktopPatch desktop properties that can be patched. +type DesktopPatch struct { + // Tags - tags to be updated + Tags map[string]*string `json:"tags"` + // DesktopPatchProperties - Detailed properties for Desktop + *DesktopPatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DesktopPatch. +func (dp DesktopPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.Tags != nil { + objectMap["tags"] = dp.Tags + } + if dp.DesktopPatchProperties != nil { + objectMap["properties"] = dp.DesktopPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DesktopPatch struct. +func (dp *DesktopPatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dp.Tags = tags + } + case "properties": + if v != nil { + var desktopPatchProperties DesktopPatchProperties + err = json.Unmarshal(*v, &desktopPatchProperties) + if err != nil { + return err + } + dp.DesktopPatchProperties = &desktopPatchProperties + } + } + } + + return nil +} + +// DesktopPatchProperties desktop properties that can be patched. +type DesktopPatchProperties struct { + // Description - Description of Desktop. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Desktop. + FriendlyName *string `json:"friendlyName,omitempty"` +} + +// DesktopProperties schema for Desktop properties. +type DesktopProperties struct { + // Description - Description of Desktop. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Desktop. + FriendlyName *string `json:"friendlyName,omitempty"` + // IconHash - READ-ONLY; Hash of the icon. + IconHash *string `json:"iconHash,omitempty"` + // IconContent - READ-ONLY; The icon a 64 bit string as a byte array. + IconContent *[]byte `json:"iconContent,omitempty"` +} + +// MarshalJSON is the custom marshaler for DesktopProperties. +func (dp DesktopProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.Description != nil { + objectMap["description"] = dp.Description + } + if dp.FriendlyName != nil { + objectMap["friendlyName"] = dp.FriendlyName + } + return json.Marshal(objectMap) +} + +// ExpandMsixImage represents the definition of contents retrieved after expanding the MSIX Image. +type ExpandMsixImage struct { + // ExpandMsixImageProperties - Detailed properties for ExpandMsixImage + *ExpandMsixImageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExpandMsixImage. +func (emi ExpandMsixImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if emi.ExpandMsixImageProperties != nil { + objectMap["properties"] = emi.ExpandMsixImageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExpandMsixImage struct. +func (emi *ExpandMsixImage) 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 expandMsixImageProperties ExpandMsixImageProperties + err = json.Unmarshal(*v, &expandMsixImageProperties) + if err != nil { + return err + } + emi.ExpandMsixImageProperties = &expandMsixImageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + emi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + emi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + emi.Type = &typeVar + } + } + } + + return nil +} + +// ExpandMsixImageList list of MSIX package properties retrieved from MSIX Image expansion. +type ExpandMsixImageList struct { + autorest.Response `json:"-"` + // Value - List of MSIX package properties from give MSIX Image. + Value *[]ExpandMsixImage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExpandMsixImageList. +func (emil ExpandMsixImageList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if emil.Value != nil { + objectMap["value"] = emil.Value + } + return json.Marshal(objectMap) +} + +// ExpandMsixImageListIterator provides access to a complete listing of ExpandMsixImage values. +type ExpandMsixImageListIterator struct { + i int + page ExpandMsixImageListPage +} + +// 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 *ExpandMsixImageListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpandMsixImageListIterator.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 *ExpandMsixImageListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExpandMsixImageListIterator) 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 ExpandMsixImageListIterator) Response() ExpandMsixImageList { + 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 ExpandMsixImageListIterator) Value() ExpandMsixImage { + if !iter.page.NotDone() { + return ExpandMsixImage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExpandMsixImageListIterator type. +func NewExpandMsixImageListIterator(page ExpandMsixImageListPage) ExpandMsixImageListIterator { + return ExpandMsixImageListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (emil ExpandMsixImageList) IsEmpty() bool { + return emil.Value == nil || len(*emil.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (emil ExpandMsixImageList) hasNextLink() bool { + return emil.NextLink != nil && len(*emil.NextLink) != 0 +} + +// expandMsixImageListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (emil ExpandMsixImageList) expandMsixImageListPreparer(ctx context.Context) (*http.Request, error) { + if !emil.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(emil.NextLink))) +} + +// ExpandMsixImageListPage contains a page of ExpandMsixImage values. +type ExpandMsixImageListPage struct { + fn func(context.Context, ExpandMsixImageList) (ExpandMsixImageList, error) + emil ExpandMsixImageList +} + +// 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 *ExpandMsixImageListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpandMsixImageListPage.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.emil) + if err != nil { + return err + } + page.emil = 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 *ExpandMsixImageListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExpandMsixImageListPage) NotDone() bool { + return !page.emil.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExpandMsixImageListPage) Response() ExpandMsixImageList { + return page.emil +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExpandMsixImageListPage) Values() []ExpandMsixImage { + if page.emil.IsEmpty() { + return nil + } + return *page.emil.Value +} + +// Creates a new instance of the ExpandMsixImageListPage type. +func NewExpandMsixImageListPage(cur ExpandMsixImageList, getNextPage func(context.Context, ExpandMsixImageList) (ExpandMsixImageList, error)) ExpandMsixImageListPage { + return ExpandMsixImageListPage{ + fn: getNextPage, + emil: cur, + } +} + +// ExpandMsixImageProperties schema for Expand MSIX Image properties. +type ExpandMsixImageProperties struct { + // PackageAlias - Alias of MSIX Package. + PackageAlias *string `json:"packageAlias,omitempty"` + // ImagePath - VHD/CIM image path on Network Share. + ImagePath *string `json:"imagePath,omitempty"` + // PackageName - Package Name from appxmanifest.xml. + PackageName *string `json:"packageName,omitempty"` + // PackageFamilyName - Package Family Name from appxmanifest.xml. Contains Package Name and Publisher name. + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + // PackageFullName - Package Full Name from appxmanifest.xml. + PackageFullName *string `json:"packageFullName,omitempty"` + // DisplayName - User friendly Name to be displayed in the portal. + DisplayName *string `json:"displayName,omitempty"` + // PackageRelativePath - Relative Path to the package inside the image. + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + // IsRegularRegistration - Specifies how to register Package in feed. + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + // IsActive - Make this version of the package the active one across the hostpool. + IsActive *bool `json:"isActive,omitempty"` + // PackageDependencies - List of package dependencies. + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + // Version - Package Version found in the appxmanifest.xml. + Version *string `json:"version,omitempty"` + // LastUpdated - Date Package was last updated, found in the appxmanifest.xml. + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + // PackageApplications - List of package applications. + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` +} + +// HostPool represents a HostPool definition. +type HostPool struct { + autorest.Response `json:"-"` + // HostPoolProperties - Detailed properties for HostPool + *HostPoolProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for HostPool. +func (hp HostPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hp.HostPoolProperties != nil { + objectMap["properties"] = hp.HostPoolProperties + } + if hp.Tags != nil { + objectMap["tags"] = hp.Tags + } + if hp.Location != nil { + objectMap["location"] = hp.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HostPool struct. +func (hp *HostPool) 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 hostPoolProperties HostPoolProperties + err = json.Unmarshal(*v, &hostPoolProperties) + if err != nil { + return err + } + hp.HostPoolProperties = &hostPoolProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + hp.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + hp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hp.Type = &typeVar + } + } + } + + return nil +} + +// HostPoolList list of HostPool definitions. +type HostPoolList struct { + autorest.Response `json:"-"` + // Value - List of HostPool definitions. + Value *[]HostPool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for HostPoolList. +func (hpl HostPoolList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hpl.Value != nil { + objectMap["value"] = hpl.Value + } + return json.Marshal(objectMap) +} + +// HostPoolListIterator provides access to a complete listing of HostPool values. +type HostPoolListIterator struct { + i int + page HostPoolListPage +} + +// 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 *HostPoolListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolListIterator.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 *HostPoolListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HostPoolListIterator) 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 HostPoolListIterator) Response() HostPoolList { + 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 HostPoolListIterator) Value() HostPool { + if !iter.page.NotDone() { + return HostPool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the HostPoolListIterator type. +func NewHostPoolListIterator(page HostPoolListPage) HostPoolListIterator { + return HostPoolListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (hpl HostPoolList) IsEmpty() bool { + return hpl.Value == nil || len(*hpl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (hpl HostPoolList) hasNextLink() bool { + return hpl.NextLink != nil && len(*hpl.NextLink) != 0 +} + +// hostPoolListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hpl HostPoolList) hostPoolListPreparer(ctx context.Context) (*http.Request, error) { + if !hpl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hpl.NextLink))) +} + +// HostPoolListPage contains a page of HostPool values. +type HostPoolListPage struct { + fn func(context.Context, HostPoolList) (HostPoolList, error) + hpl HostPoolList +} + +// 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 *HostPoolListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostPoolListPage.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.hpl) + if err != nil { + return err + } + page.hpl = 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 *HostPoolListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HostPoolListPage) NotDone() bool { + return !page.hpl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HostPoolListPage) Response() HostPoolList { + return page.hpl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HostPoolListPage) Values() []HostPool { + if page.hpl.IsEmpty() { + return nil + } + return *page.hpl.Value +} + +// Creates a new instance of the HostPoolListPage type. +func NewHostPoolListPage(cur HostPoolList, getNextPage func(context.Context, HostPoolList) (HostPoolList, error)) HostPoolListPage { + return HostPoolListPage{ + fn: getNextPage, + hpl: cur, + } +} + +// HostPoolPatch hostPool properties that can be patched. +type HostPoolPatch struct { + // Tags - tags to be updated + Tags map[string]*string `json:"tags"` + // HostPoolPatchProperties - HostPool properties that can be patched. + *HostPoolPatchProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for HostPoolPatch. +func (hpp HostPoolPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hpp.Tags != nil { + objectMap["tags"] = hpp.Tags + } + if hpp.HostPoolPatchProperties != nil { + objectMap["properties"] = hpp.HostPoolPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HostPoolPatch struct. +func (hpp *HostPoolPatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + hpp.Tags = tags + } + case "properties": + if v != nil { + var hostPoolPatchProperties HostPoolPatchProperties + err = json.Unmarshal(*v, &hostPoolPatchProperties) + if err != nil { + return err + } + hpp.HostPoolPatchProperties = &hostPoolPatchProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hpp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hpp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hpp.Type = &typeVar + } + } + } + + return nil +} + +// HostPoolPatchProperties properties of HostPool. +type HostPoolPatchProperties struct { + // FriendlyName - Friendly name of HostPool. + FriendlyName *string `json:"friendlyName,omitempty"` + // Description - Description of HostPool. + Description *string `json:"description,omitempty"` + // CustomRdpProperty - Custom rdp property of HostPool. + CustomRdpProperty *string `json:"customRdpProperty,omitempty"` + // MaxSessionLimit - The max session limit of HostPool. + MaxSessionLimit *int32 `json:"maxSessionLimit,omitempty"` + // PersonalDesktopAssignmentType - PersonalDesktopAssignment type for HostPool. Possible values include: 'Automatic', 'Direct' + PersonalDesktopAssignmentType PersonalDesktopAssignmentType `json:"personalDesktopAssignmentType,omitempty"` + // LoadBalancerType - The type of the load balancer. Possible values include: 'BreadthFirst', 'DepthFirst', 'Persistent' + LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"` + // Ring - The ring number of HostPool. + Ring *int32 `json:"ring,omitempty"` + // ValidationEnvironment - Is validation environment. + ValidationEnvironment *bool `json:"validationEnvironment,omitempty"` + // RegistrationInfo - The registration info of HostPool. + RegistrationInfo *RegistrationInfoPatch `json:"registrationInfo,omitempty"` + // VMTemplate - VM template for sessionhosts configuration within hostpool. + VMTemplate *string `json:"vmTemplate,omitempty"` + // SsoContext - Path to keyvault containing ssoContext secret. + SsoContext *string `json:"ssoContext,omitempty"` + // SsoadfsAuthority - URL to customer ADFS server for signing WVD SSO certificates. + SsoadfsAuthority *string `json:"ssoadfsAuthority,omitempty"` + // SsoClientID - ClientId for the registered Relying Party used to issue WVD SSO certificates. + SsoClientID *string `json:"ssoClientId,omitempty"` + // SsoClientSecretKeyVaultPath - Path to Azure KeyVault storing the secret used for communication to ADFS. + SsoClientSecretKeyVaultPath *string `json:"ssoClientSecretKeyVaultPath,omitempty"` + // SsoSecretType - The type of single sign on Secret Type. Possible values include: 'SharedKey', 'Certificate', 'SharedKeyInKeyVault', 'CertificateInKeyVault' + SsoSecretType SSOSecretType `json:"ssoSecretType,omitempty"` + // PreferredAppGroupType - The type of preferred application group type, default to Desktop Application Group. Possible values include: 'PreferredAppGroupTypeNone', 'PreferredAppGroupTypeDesktop', 'PreferredAppGroupTypeRailApplications' + PreferredAppGroupType PreferredAppGroupType `json:"preferredAppGroupType,omitempty"` +} + +// HostPoolProperties properties of HostPool. +type HostPoolProperties struct { + // FriendlyName - Friendly name of HostPool. + FriendlyName *string `json:"friendlyName,omitempty"` + // Description - Description of HostPool. + Description *string `json:"description,omitempty"` + // HostPoolType - HostPool type for desktop. Possible values include: 'Personal', 'Pooled' + HostPoolType HostPoolType `json:"hostPoolType,omitempty"` + // PersonalDesktopAssignmentType - PersonalDesktopAssignment type for HostPool. Possible values include: 'Automatic', 'Direct' + PersonalDesktopAssignmentType PersonalDesktopAssignmentType `json:"personalDesktopAssignmentType,omitempty"` + // CustomRdpProperty - Custom rdp property of HostPool. + CustomRdpProperty *string `json:"customRdpProperty,omitempty"` + // MaxSessionLimit - The max session limit of HostPool. + MaxSessionLimit *int32 `json:"maxSessionLimit,omitempty"` + // LoadBalancerType - The type of the load balancer. Possible values include: 'BreadthFirst', 'DepthFirst', 'Persistent' + LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"` + // Ring - The ring number of HostPool. + Ring *int32 `json:"ring,omitempty"` + // ValidationEnvironment - Is validation environment. + ValidationEnvironment *bool `json:"validationEnvironment,omitempty"` + // RegistrationInfo - The registration info of HostPool. + RegistrationInfo *RegistrationInfo `json:"registrationInfo,omitempty"` + // VMTemplate - VM template for sessionhosts configuration within hostpool. + VMTemplate *string `json:"vmTemplate,omitempty"` + // ApplicationGroupReferences - READ-ONLY; List of applicationGroup links. + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` + // SsoContext - Path to keyvault containing ssoContext secret. + SsoContext *string `json:"ssoContext,omitempty"` + // SsoadfsAuthority - URL to customer ADFS server for signing WVD SSO certificates. + SsoadfsAuthority *string `json:"ssoadfsAuthority,omitempty"` + // SsoClientID - ClientId for the registered Relying Party used to issue WVD SSO certificates. + SsoClientID *string `json:"ssoClientId,omitempty"` + // SsoClientSecretKeyVaultPath - Path to Azure KeyVault storing the secret used for communication to ADFS. + SsoClientSecretKeyVaultPath *string `json:"ssoClientSecretKeyVaultPath,omitempty"` + // SsoSecretType - The type of single sign on Secret Type. Possible values include: 'SharedKey', 'Certificate', 'SharedKeyInKeyVault', 'CertificateInKeyVault' + SsoSecretType SSOSecretType `json:"ssoSecretType,omitempty"` + // PreferredAppGroupType - The type of preferred application group type, default to Desktop Application Group. Possible values include: 'PreferredAppGroupTypeNone', 'PreferredAppGroupTypeDesktop', 'PreferredAppGroupTypeRailApplications' + PreferredAppGroupType PreferredAppGroupType `json:"preferredAppGroupType,omitempty"` +} + +// MarshalJSON is the custom marshaler for HostPoolProperties. +func (hpp HostPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hpp.FriendlyName != nil { + objectMap["friendlyName"] = hpp.FriendlyName + } + if hpp.Description != nil { + objectMap["description"] = hpp.Description + } + if hpp.HostPoolType != "" { + objectMap["hostPoolType"] = hpp.HostPoolType + } + if hpp.PersonalDesktopAssignmentType != "" { + objectMap["personalDesktopAssignmentType"] = hpp.PersonalDesktopAssignmentType + } + if hpp.CustomRdpProperty != nil { + objectMap["customRdpProperty"] = hpp.CustomRdpProperty + } + if hpp.MaxSessionLimit != nil { + objectMap["maxSessionLimit"] = hpp.MaxSessionLimit + } + if hpp.LoadBalancerType != "" { + objectMap["loadBalancerType"] = hpp.LoadBalancerType + } + if hpp.Ring != nil { + objectMap["ring"] = hpp.Ring + } + if hpp.ValidationEnvironment != nil { + objectMap["validationEnvironment"] = hpp.ValidationEnvironment + } + if hpp.RegistrationInfo != nil { + objectMap["registrationInfo"] = hpp.RegistrationInfo + } + if hpp.VMTemplate != nil { + objectMap["vmTemplate"] = hpp.VMTemplate + } + if hpp.SsoContext != nil { + objectMap["ssoContext"] = hpp.SsoContext + } + if hpp.SsoadfsAuthority != nil { + objectMap["ssoadfsAuthority"] = hpp.SsoadfsAuthority + } + if hpp.SsoClientID != nil { + objectMap["ssoClientId"] = hpp.SsoClientID + } + if hpp.SsoClientSecretKeyVaultPath != nil { + objectMap["ssoClientSecretKeyVaultPath"] = hpp.SsoClientSecretKeyVaultPath + } + if hpp.SsoSecretType != "" { + objectMap["ssoSecretType"] = hpp.SsoSecretType + } + if hpp.PreferredAppGroupType != "" { + objectMap["preferredAppGroupType"] = hpp.PreferredAppGroupType + } + return json.Marshal(objectMap) +} + +// MSIXImageURI represents URI referring to MSIX Image +type MSIXImageURI struct { + // URI - URI to Image + URI *string `json:"uri,omitempty"` +} + +// MSIXPackage schema for MSIX Package properties. +type MSIXPackage struct { + autorest.Response `json:"-"` + // MSIXPackageProperties - Detailed properties for MSIX Package + *MSIXPackageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MSIXPackage. +func (mp MSIXPackage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mp.MSIXPackageProperties != nil { + objectMap["properties"] = mp.MSIXPackageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MSIXPackage struct. +func (mp *MSIXPackage) 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 mSIXPackageProperties MSIXPackageProperties + err = json.Unmarshal(*v, &mSIXPackageProperties) + if err != nil { + return err + } + mp.MSIXPackageProperties = &mSIXPackageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mp.Type = &typeVar + } + } + } + + return nil +} + +// MsixPackageApplications schema for MSIX Package Application properties. +type MsixPackageApplications struct { + // AppID - Package Application Id, found in appxmanifest.xml. + AppID *string `json:"appId,omitempty"` + // Description - Description of Package Application. + Description *string `json:"description,omitempty"` + // AppUserModelID - Used to activate Package Application. Consists of Package Name and ApplicationID. Found in appxmanifest.xml. + AppUserModelID *string `json:"appUserModelID,omitempty"` + // FriendlyName - User friendly name. + FriendlyName *string `json:"friendlyName,omitempty"` + // IconImageName - User friendly name. + IconImageName *string `json:"iconImageName,omitempty"` + // RawIcon - the icon a 64 bit string as a byte array. + RawIcon *[]byte `json:"rawIcon,omitempty"` + // RawPng - the icon a 64 bit string as a byte array. + RawPng *[]byte `json:"rawPng,omitempty"` +} + +// MsixPackageDependencies schema for MSIX Package Dependencies properties. +type MsixPackageDependencies struct { + // DependencyName - Name of package dependency. + DependencyName *string `json:"dependencyName,omitempty"` + // Publisher - Name of dependency publisher. + Publisher *string `json:"publisher,omitempty"` + // MinVersion - Dependency version required. + MinVersion *string `json:"minVersion,omitempty"` +} + +// MSIXPackageList list of MSIX Package definitions. +type MSIXPackageList struct { + autorest.Response `json:"-"` + // Value - List of MSIX Package definitions. + Value *[]MSIXPackage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for MSIXPackageList. +func (mpl MSIXPackageList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mpl.Value != nil { + objectMap["value"] = mpl.Value + } + return json.Marshal(objectMap) +} + +// MSIXPackageListIterator provides access to a complete listing of MSIXPackage values. +type MSIXPackageListIterator struct { + i int + page MSIXPackageListPage +} + +// 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 *MSIXPackageListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackageListIterator.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 *MSIXPackageListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MSIXPackageListIterator) 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 MSIXPackageListIterator) Response() MSIXPackageList { + 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 MSIXPackageListIterator) Value() MSIXPackage { + if !iter.page.NotDone() { + return MSIXPackage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MSIXPackageListIterator type. +func NewMSIXPackageListIterator(page MSIXPackageListPage) MSIXPackageListIterator { + return MSIXPackageListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mpl MSIXPackageList) IsEmpty() bool { + return mpl.Value == nil || len(*mpl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mpl MSIXPackageList) hasNextLink() bool { + return mpl.NextLink != nil && len(*mpl.NextLink) != 0 +} + +// mSIXPackageListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mpl MSIXPackageList) mSIXPackageListPreparer(ctx context.Context) (*http.Request, error) { + if !mpl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mpl.NextLink))) +} + +// MSIXPackageListPage contains a page of MSIXPackage values. +type MSIXPackageListPage struct { + fn func(context.Context, MSIXPackageList) (MSIXPackageList, error) + mpl MSIXPackageList +} + +// 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 *MSIXPackageListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackageListPage.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.mpl) + if err != nil { + return err + } + page.mpl = 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 *MSIXPackageListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MSIXPackageListPage) NotDone() bool { + return !page.mpl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MSIXPackageListPage) Response() MSIXPackageList { + return page.mpl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MSIXPackageListPage) Values() []MSIXPackage { + if page.mpl.IsEmpty() { + return nil + } + return *page.mpl.Value +} + +// Creates a new instance of the MSIXPackageListPage type. +func NewMSIXPackageListPage(cur MSIXPackageList, getNextPage func(context.Context, MSIXPackageList) (MSIXPackageList, error)) MSIXPackageListPage { + return MSIXPackageListPage{ + fn: getNextPage, + mpl: cur, + } +} + +// MSIXPackagePatch MSIX Package properties that can be patched. +type MSIXPackagePatch struct { + // MSIXPackagePatchProperties - Detailed properties for MSIX Package + *MSIXPackagePatchProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MSIXPackagePatch. +func (mpp MSIXPackagePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mpp.MSIXPackagePatchProperties != nil { + objectMap["properties"] = mpp.MSIXPackagePatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MSIXPackagePatch struct. +func (mpp *MSIXPackagePatch) 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 mSIXPackagePatchProperties MSIXPackagePatchProperties + err = json.Unmarshal(*v, &mSIXPackagePatchProperties) + if err != nil { + return err + } + mpp.MSIXPackagePatchProperties = &mSIXPackagePatchProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mpp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mpp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mpp.Type = &typeVar + } + } + } + + return nil +} + +// MSIXPackagePatchProperties MSIX Package properties that can be patched. +type MSIXPackagePatchProperties struct { + // IsActive - Set a version of the package to be active across hostpool. + IsActive *bool `json:"isActive,omitempty"` + // IsRegularRegistration - Set Registration mode. Regular or Delayed. + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + // DisplayName - Display name for MSIX Package. + DisplayName *string `json:"displayName,omitempty"` +} + +// MSIXPackageProperties schema for MSIX Package properties. +type MSIXPackageProperties struct { + // ImagePath - VHD/CIM image path on Network Share. + ImagePath *string `json:"imagePath,omitempty"` + // PackageName - Package Name from appxmanifest.xml. + PackageName *string `json:"packageName,omitempty"` + // PackageFamilyName - Package Family Name from appxmanifest.xml. Contains Package Name and Publisher name. + PackageFamilyName *string `json:"packageFamilyName,omitempty"` + // DisplayName - User friendly Name to be displayed in the portal. + DisplayName *string `json:"displayName,omitempty"` + // PackageRelativePath - Relative Path to the package inside the image. + PackageRelativePath *string `json:"packageRelativePath,omitempty"` + // IsRegularRegistration - Specifies how to register Package in feed. + IsRegularRegistration *bool `json:"isRegularRegistration,omitempty"` + // IsActive - Make this version of the package the active one across the hostpool. + IsActive *bool `json:"isActive,omitempty"` + // PackageDependencies - List of package dependencies. + PackageDependencies *[]MsixPackageDependencies `json:"packageDependencies,omitempty"` + // Version - Package Version found in the appxmanifest.xml. + Version *string `json:"version,omitempty"` + // LastUpdated - Date Package was last updated, found in the appxmanifest.xml. + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + // PackageApplications - List of package applications. + PackageApplications *[]MsixPackageApplications `json:"packageApplications,omitempty"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// RegistrationInfo represents a RegistrationInfo definition. +type RegistrationInfo struct { + // ExpirationTime - Expiration time of registration token. + ExpirationTime *date.Time `json:"expirationTime,omitempty"` + // Token - The registration token base64 encoded string. + Token *string `json:"token,omitempty"` + // RegistrationTokenOperation - The type of resetting the token. Possible values include: 'Delete', 'None', 'Update' + RegistrationTokenOperation RegistrationTokenOperation `json:"registrationTokenOperation,omitempty"` +} + +// RegistrationInfoPatch represents a RegistrationInfo definition. +type RegistrationInfoPatch struct { + // ExpirationTime - Expiration time of registration token. + ExpirationTime *date.Time `json:"expirationTime,omitempty"` + // RegistrationTokenOperation - The type of resetting the token. Possible values include: 'Delete', 'None', 'Update' + RegistrationTokenOperation RegistrationTokenOperation `json:"registrationTokenOperation,omitempty"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// ResourceProviderOperation supported operation of this resource provider. +type ResourceProviderOperation struct { + // Name - Operation name, in format of {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` +} + +// ResourceProviderOperationDisplay display metadata associated with the operation. +type ResourceProviderOperationDisplay struct { + // Provider - Resource provider: Microsoft Desktop Virtualization. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description of this operation. + Description *string `json:"description,omitempty"` +} + +// ResourceProviderOperationList result of the request to list operations. +type ResourceProviderOperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by this resource provider. + Value *[]ResourceProviderOperation `json:"value,omitempty"` +} + +// SendMessage represents message sent to a UserSession. +type SendMessage struct { + // MessageTitle - Title of message. + MessageTitle *string `json:"messageTitle,omitempty"` + // MessageBody - Body of message. + MessageBody *string `json:"messageBody,omitempty"` +} + +// SessionHost represents a SessionHost definition. +type SessionHost struct { + autorest.Response `json:"-"` + // SessionHostProperties - Detailed properties for SessionHost + *SessionHostProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SessionHost. +func (sh SessionHost) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sh.SessionHostProperties != nil { + objectMap["properties"] = sh.SessionHostProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SessionHost struct. +func (sh *SessionHost) 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 sessionHostProperties SessionHostProperties + err = json.Unmarshal(*v, &sessionHostProperties) + if err != nil { + return err + } + sh.SessionHostProperties = &sessionHostProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sh.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sh.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sh.Type = &typeVar + } + } + } + + return nil +} + +// SessionHostList list of SessionHost definitions. +type SessionHostList struct { + autorest.Response `json:"-"` + // Value - List of SessionHost definitions. + Value *[]SessionHost `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SessionHostList. +func (shl SessionHostList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if shl.Value != nil { + objectMap["value"] = shl.Value + } + return json.Marshal(objectMap) +} + +// SessionHostListIterator provides access to a complete listing of SessionHost values. +type SessionHostListIterator struct { + i int + page SessionHostListPage +} + +// 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 *SessionHostListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostListIterator.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 *SessionHostListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SessionHostListIterator) 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 SessionHostListIterator) Response() SessionHostList { + 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 SessionHostListIterator) Value() SessionHost { + if !iter.page.NotDone() { + return SessionHost{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SessionHostListIterator type. +func NewSessionHostListIterator(page SessionHostListPage) SessionHostListIterator { + return SessionHostListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (shl SessionHostList) IsEmpty() bool { + return shl.Value == nil || len(*shl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (shl SessionHostList) hasNextLink() bool { + return shl.NextLink != nil && len(*shl.NextLink) != 0 +} + +// sessionHostListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (shl SessionHostList) sessionHostListPreparer(ctx context.Context) (*http.Request, error) { + if !shl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(shl.NextLink))) +} + +// SessionHostListPage contains a page of SessionHost values. +type SessionHostListPage struct { + fn func(context.Context, SessionHostList) (SessionHostList, error) + shl SessionHostList +} + +// 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 *SessionHostListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostListPage.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.shl) + if err != nil { + return err + } + page.shl = 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 *SessionHostListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SessionHostListPage) NotDone() bool { + return !page.shl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SessionHostListPage) Response() SessionHostList { + return page.shl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SessionHostListPage) Values() []SessionHost { + if page.shl.IsEmpty() { + return nil + } + return *page.shl.Value +} + +// Creates a new instance of the SessionHostListPage type. +func NewSessionHostListPage(cur SessionHostList, getNextPage func(context.Context, SessionHostList) (SessionHostList, error)) SessionHostListPage { + return SessionHostListPage{ + fn: getNextPage, + shl: cur, + } +} + +// SessionHostPatch sessionHost properties that can be patched. +type SessionHostPatch struct { + // SessionHostPatchProperties - Detailed properties for SessionHost + *SessionHostPatchProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SessionHostPatch. +func (shp SessionHostPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if shp.SessionHostPatchProperties != nil { + objectMap["properties"] = shp.SessionHostPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SessionHostPatch struct. +func (shp *SessionHostPatch) 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 sessionHostPatchProperties SessionHostPatchProperties + err = json.Unmarshal(*v, &sessionHostPatchProperties) + if err != nil { + return err + } + shp.SessionHostPatchProperties = &sessionHostPatchProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + shp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + shp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + shp.Type = &typeVar + } + } + } + + return nil +} + +// SessionHostPatchProperties sessionHost properties that can be patched. +type SessionHostPatchProperties struct { + // AllowNewSession - Allow a new session. + AllowNewSession *bool `json:"allowNewSession,omitempty"` + // AssignedUser - User assigned to SessionHost. + AssignedUser *string `json:"assignedUser,omitempty"` +} + +// SessionHostProperties schema for SessionHost properties. +type SessionHostProperties struct { + // LastHeartBeat - Last heart beat from SessionHost. + LastHeartBeat *date.Time `json:"lastHeartBeat,omitempty"` + // Sessions - Number of sessions on SessionHost. + Sessions *int32 `json:"sessions,omitempty"` + // AgentVersion - Version of agent on SessionHost. + AgentVersion *string `json:"agentVersion,omitempty"` + // AllowNewSession - Allow a new session. + AllowNewSession *bool `json:"allowNewSession,omitempty"` + // VirtualMachineID - READ-ONLY; Virtual Machine Id of SessionHost's underlying virtual machine. + VirtualMachineID *string `json:"virtualMachineId,omitempty"` + // ResourceID - READ-ONLY; Resource Id of SessionHost's underlying virtual machine. + ResourceID *string `json:"resourceId,omitempty"` + // AssignedUser - User assigned to SessionHost. + AssignedUser *string `json:"assignedUser,omitempty"` + // Status - Status for a SessionHost. Possible values include: 'StatusAvailable', 'StatusUnavailable', 'StatusShutdown', 'StatusDisconnected', 'StatusUpgrading', 'StatusUpgradeFailed' + Status Status `json:"status,omitempty"` + // StatusTimestamp - READ-ONLY; The timestamp of the status. + StatusTimestamp *date.Time `json:"statusTimestamp,omitempty"` + // OsVersion - The version of the OS on the session host. + OsVersion *string `json:"osVersion,omitempty"` + // SxSStackVersion - The version of the side by side stack on the session host. + SxSStackVersion *string `json:"sxSStackVersion,omitempty"` + // UpdateState - Update state of a SessionHost. Possible values include: 'UpdateStateInitial', 'UpdateStatePending', 'UpdateStateStarted', 'UpdateStateSucceeded', 'UpdateStateFailed' + UpdateState UpdateState `json:"updateState,omitempty"` + // LastUpdateTime - READ-ONLY; The timestamp of the last update. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` + // UpdateErrorMessage - The error message. + UpdateErrorMessage *string `json:"updateErrorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for SessionHostProperties. +func (shp SessionHostProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if shp.LastHeartBeat != nil { + objectMap["lastHeartBeat"] = shp.LastHeartBeat + } + if shp.Sessions != nil { + objectMap["sessions"] = shp.Sessions + } + if shp.AgentVersion != nil { + objectMap["agentVersion"] = shp.AgentVersion + } + if shp.AllowNewSession != nil { + objectMap["allowNewSession"] = shp.AllowNewSession + } + if shp.AssignedUser != nil { + objectMap["assignedUser"] = shp.AssignedUser + } + if shp.Status != "" { + objectMap["status"] = shp.Status + } + if shp.OsVersion != nil { + objectMap["osVersion"] = shp.OsVersion + } + if shp.SxSStackVersion != nil { + objectMap["sxSStackVersion"] = shp.SxSStackVersion + } + if shp.UpdateState != "" { + objectMap["updateState"] = shp.UpdateState + } + if shp.UpdateErrorMessage != nil { + objectMap["updateErrorMessage"] = shp.UpdateErrorMessage + } + return json.Marshal(objectMap) +} + +// StartMenuItem represents a StartMenuItem definition. +type StartMenuItem struct { + // StartMenuItemProperties - Detailed properties for StartMenuItem + *StartMenuItemProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for StartMenuItem. +func (smi StartMenuItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smi.StartMenuItemProperties != nil { + objectMap["properties"] = smi.StartMenuItemProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for StartMenuItem struct. +func (smi *StartMenuItem) 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 startMenuItemProperties StartMenuItemProperties + err = json.Unmarshal(*v, &startMenuItemProperties) + if err != nil { + return err + } + smi.StartMenuItemProperties = &startMenuItemProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + smi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + smi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + smi.Type = &typeVar + } + } + } + + return nil +} + +// StartMenuItemList list of StartMenuItem definitions. +type StartMenuItemList struct { + autorest.Response `json:"-"` + // Value - List of StartMenuItem definitions. + Value *[]StartMenuItem `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for StartMenuItemList. +func (smil StartMenuItemList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smil.Value != nil { + objectMap["value"] = smil.Value + } + return json.Marshal(objectMap) +} + +// StartMenuItemListIterator provides access to a complete listing of StartMenuItem values. +type StartMenuItemListIterator struct { + i int + page StartMenuItemListPage +} + +// 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 *StartMenuItemListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StartMenuItemListIterator.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 *StartMenuItemListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter StartMenuItemListIterator) 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 StartMenuItemListIterator) Response() StartMenuItemList { + 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 StartMenuItemListIterator) Value() StartMenuItem { + if !iter.page.NotDone() { + return StartMenuItem{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the StartMenuItemListIterator type. +func NewStartMenuItemListIterator(page StartMenuItemListPage) StartMenuItemListIterator { + return StartMenuItemListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (smil StartMenuItemList) IsEmpty() bool { + return smil.Value == nil || len(*smil.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (smil StartMenuItemList) hasNextLink() bool { + return smil.NextLink != nil && len(*smil.NextLink) != 0 +} + +// startMenuItemListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smil StartMenuItemList) startMenuItemListPreparer(ctx context.Context) (*http.Request, error) { + if !smil.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smil.NextLink))) +} + +// StartMenuItemListPage contains a page of StartMenuItem values. +type StartMenuItemListPage struct { + fn func(context.Context, StartMenuItemList) (StartMenuItemList, error) + smil StartMenuItemList +} + +// 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 *StartMenuItemListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StartMenuItemListPage.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.smil) + if err != nil { + return err + } + page.smil = 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 *StartMenuItemListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page StartMenuItemListPage) NotDone() bool { + return !page.smil.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page StartMenuItemListPage) Response() StartMenuItemList { + return page.smil +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page StartMenuItemListPage) Values() []StartMenuItem { + if page.smil.IsEmpty() { + return nil + } + return *page.smil.Value +} + +// Creates a new instance of the StartMenuItemListPage type. +func NewStartMenuItemListPage(cur StartMenuItemList, getNextPage func(context.Context, StartMenuItemList) (StartMenuItemList, error)) StartMenuItemListPage { + return StartMenuItemListPage{ + fn: getNextPage, + smil: cur, + } +} + +// StartMenuItemProperties schema for StartMenuItem properties. +type StartMenuItemProperties struct { + // AppAlias - Alias of StartMenuItem. + AppAlias *string `json:"appAlias,omitempty"` + // FriendlyName - Friendly name of StartMenuItem. + FriendlyName *string `json:"friendlyName,omitempty"` + // FilePath - Path to the file of StartMenuItem. + FilePath *string `json:"filePath,omitempty"` + // CommandLineArguments - Command line arguments for StartMenuItem. + CommandLineArguments *string `json:"commandLineArguments,omitempty"` + // IconPath - Path to the icon. + IconPath *string `json:"iconPath,omitempty"` + // IconIndex - Index of the icon. + IconIndex *int32 `json:"iconIndex,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UserSession represents a UserSession definition. +type UserSession struct { + autorest.Response `json:"-"` + // UserSessionProperties - Detailed properties for UserSession + *UserSessionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserSession. +func (us UserSession) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if us.UserSessionProperties != nil { + objectMap["properties"] = us.UserSessionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UserSession struct. +func (us *UserSession) 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 userSessionProperties UserSessionProperties + err = json.Unmarshal(*v, &userSessionProperties) + if err != nil { + return err + } + us.UserSessionProperties = &userSessionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + us.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + us.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + us.Type = &typeVar + } + } + } + + return nil +} + +// UserSessionList list of UserSession definitions. +type UserSessionList struct { + autorest.Response `json:"-"` + // Value - List of UserSession definitions. + Value *[]UserSession `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserSessionList. +func (usl UserSessionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if usl.Value != nil { + objectMap["value"] = usl.Value + } + return json.Marshal(objectMap) +} + +// UserSessionListIterator provides access to a complete listing of UserSession values. +type UserSessionListIterator struct { + i int + page UserSessionListPage +} + +// 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 *UserSessionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionListIterator.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 *UserSessionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UserSessionListIterator) 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 UserSessionListIterator) Response() UserSessionList { + 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 UserSessionListIterator) Value() UserSession { + if !iter.page.NotDone() { + return UserSession{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UserSessionListIterator type. +func NewUserSessionListIterator(page UserSessionListPage) UserSessionListIterator { + return UserSessionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (usl UserSessionList) IsEmpty() bool { + return usl.Value == nil || len(*usl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (usl UserSessionList) hasNextLink() bool { + return usl.NextLink != nil && len(*usl.NextLink) != 0 +} + +// userSessionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (usl UserSessionList) userSessionListPreparer(ctx context.Context) (*http.Request, error) { + if !usl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(usl.NextLink))) +} + +// UserSessionListPage contains a page of UserSession values. +type UserSessionListPage struct { + fn func(context.Context, UserSessionList) (UserSessionList, error) + usl UserSessionList +} + +// 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 *UserSessionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionListPage.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.usl) + if err != nil { + return err + } + page.usl = 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 *UserSessionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UserSessionListPage) NotDone() bool { + return !page.usl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UserSessionListPage) Response() UserSessionList { + return page.usl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UserSessionListPage) Values() []UserSession { + if page.usl.IsEmpty() { + return nil + } + return *page.usl.Value +} + +// Creates a new instance of the UserSessionListPage type. +func NewUserSessionListPage(cur UserSessionList, getNextPage func(context.Context, UserSessionList) (UserSessionList, error)) UserSessionListPage { + return UserSessionListPage{ + fn: getNextPage, + usl: cur, + } +} + +// UserSessionProperties schema for UserSession properties. +type UserSessionProperties struct { + // UserPrincipalName - The user principal name. + UserPrincipalName *string `json:"userPrincipalName,omitempty"` + // ApplicationType - Application type of application. Possible values include: 'ApplicationTypeRemoteApp', 'ApplicationTypeDesktop' + ApplicationType ApplicationType `json:"applicationType,omitempty"` + // SessionState - State of user session. Possible values include: 'Unknown', 'Active', 'Disconnected', 'Pending', 'LogOff', 'UserProfileDiskMounted' + SessionState SessionState `json:"sessionState,omitempty"` + // ActiveDirectoryUserName - The active directory user name. + ActiveDirectoryUserName *string `json:"activeDirectoryUserName,omitempty"` + // CreateTime - The timestamp of the user session create. + CreateTime *date.Time `json:"createTime,omitempty"` +} + +// Workspace represents a Workspace definition. +type Workspace struct { + autorest.Response `json:"-"` + // WorkspaceProperties - Detailed properties for Workspace + *WorkspaceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WorkspaceProperties != nil { + objectMap["properties"] = w.WorkspaceProperties + } + if w.Tags != nil { + objectMap["tags"] = w.Tags + } + if w.Location != nil { + objectMap["location"] = w.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Workspace struct. +func (w *Workspace) 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 workspaceProperties WorkspaceProperties + err = json.Unmarshal(*v, &workspaceProperties) + if err != nil { + return err + } + w.WorkspaceProperties = &workspaceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + w.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + w.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WorkspaceList list of Workspace definitions. +type WorkspaceList struct { + autorest.Response `json:"-"` + // Value - List of Workspace definitions. + Value *[]Workspace `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceList. +func (wl WorkspaceList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wl.Value != nil { + objectMap["value"] = wl.Value + } + return json.Marshal(objectMap) +} + +// WorkspaceListIterator provides access to a complete listing of Workspace values. +type WorkspaceListIterator struct { + i int + page WorkspaceListPage +} + +// 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 *WorkspaceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListIterator.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 *WorkspaceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkspaceListIterator) 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 WorkspaceListIterator) Response() WorkspaceList { + 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 WorkspaceListIterator) Value() Workspace { + if !iter.page.NotDone() { + return Workspace{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkspaceListIterator type. +func NewWorkspaceListIterator(page WorkspaceListPage) WorkspaceListIterator { + return WorkspaceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wl WorkspaceList) IsEmpty() bool { + return wl.Value == nil || len(*wl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wl WorkspaceList) hasNextLink() bool { + return wl.NextLink != nil && len(*wl.NextLink) != 0 +} + +// workspaceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wl WorkspaceList) workspaceListPreparer(ctx context.Context) (*http.Request, error) { + if !wl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wl.NextLink))) +} + +// WorkspaceListPage contains a page of Workspace values. +type WorkspaceListPage struct { + fn func(context.Context, WorkspaceList) (WorkspaceList, error) + wl WorkspaceList +} + +// 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 *WorkspaceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListPage.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.wl) + if err != nil { + return err + } + page.wl = 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 *WorkspaceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkspaceListPage) NotDone() bool { + return !page.wl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkspaceListPage) Response() WorkspaceList { + return page.wl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkspaceListPage) Values() []Workspace { + if page.wl.IsEmpty() { + return nil + } + return *page.wl.Value +} + +// Creates a new instance of the WorkspaceListPage type. +func NewWorkspaceListPage(cur WorkspaceList, getNextPage func(context.Context, WorkspaceList) (WorkspaceList, error)) WorkspaceListPage { + return WorkspaceListPage{ + fn: getNextPage, + wl: cur, + } +} + +// WorkspacePatch workspace properties that can be patched. +type WorkspacePatch struct { + // Tags - tags to be updated + Tags map[string]*string `json:"tags"` + // WorkspacePatchProperties - Detailed properties for Workspace + *WorkspacePatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspacePatch. +func (wp WorkspacePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.Tags != nil { + objectMap["tags"] = wp.Tags + } + if wp.WorkspacePatchProperties != nil { + objectMap["properties"] = wp.WorkspacePatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkspacePatch struct. +func (wp *WorkspacePatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wp.Tags = tags + } + case "properties": + if v != nil { + var workspacePatchProperties WorkspacePatchProperties + err = json.Unmarshal(*v, &workspacePatchProperties) + if err != nil { + return err + } + wp.WorkspacePatchProperties = &workspacePatchProperties + } + } + } + + return nil +} + +// WorkspacePatchProperties workspace properties that can be patched. +type WorkspacePatchProperties struct { + // Description - Description of Workspace. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Workspace. + FriendlyName *string `json:"friendlyName,omitempty"` + // ApplicationGroupReferences - List of applicationGroup links. + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` +} + +// WorkspaceProperties schema for Workspace properties. +type WorkspaceProperties struct { + // Description - Description of Workspace. + Description *string `json:"description,omitempty"` + // FriendlyName - Friendly name of Workspace. + FriendlyName *string `json:"friendlyName,omitempty"` + // ApplicationGroupReferences - List of applicationGroup resource Ids. + ApplicationGroupReferences *[]string `json:"applicationGroupReferences,omitempty"` +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msiximages.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msiximages.go new file mode 100644 index 000000000000..c521aa18a251 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msiximages.go @@ -0,0 +1,175 @@ +package desktopvirtualization + +// 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" +) + +// MsixImagesClient is the client for the MsixImages methods of the Desktopvirtualization service. +type MsixImagesClient struct { + BaseClient +} + +// NewMsixImagesClient creates an instance of the MsixImagesClient client. +func NewMsixImagesClient(subscriptionID string) MsixImagesClient { + return NewMsixImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMsixImagesClientWithBaseURI creates an instance of the MsixImagesClient 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 NewMsixImagesClientWithBaseURI(baseURI string, subscriptionID string) MsixImagesClient { + return MsixImagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Expand expands and Lists MSIX packages in an Image, given the Image Path. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// msixImageURI - object containing URI to MSIX Image +func (client MsixImagesClient) Expand(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (result ExpandMsixImageListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MsixImagesClient.Expand") + defer func() { + sc := -1 + if result.emil.Response.Response != nil { + sc = result.emil.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MsixImagesClient", "Expand", err.Error()) + } + + result.fn = client.expandNextResults + req, err := client.ExpandPreparer(ctx, resourceGroupName, hostPoolName, msixImageURI) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", nil, "Failure preparing request") + return + } + + resp, err := client.ExpandSender(req) + if err != nil { + result.emil.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", resp, "Failure sending request") + return + } + + result.emil, err = client.ExpandResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", resp, "Failure responding to request") + } + if result.emil.hasNextLink() && result.emil.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ExpandPreparer prepares the Expand request. +func (client MsixImagesClient) ExpandPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage", pathParameters), + autorest.WithJSON(msixImageURI), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExpandSender sends the Expand request. The method will close the +// http.Response Body if it receives an error. +func (client MsixImagesClient) ExpandSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExpandResponder handles the response to the Expand request. The method always +// closes the http.Response Body. +func (client MsixImagesClient) ExpandResponder(resp *http.Response) (result ExpandMsixImageList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// expandNextResults retrieves the next set of results, if any. +func (client MsixImagesClient) expandNextResults(ctx context.Context, lastResults ExpandMsixImageList) (result ExpandMsixImageList, err error) { + req, err := lastResults.expandMsixImageListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ExpandSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", resp, "Failure sending next results request") + } + result, err = client.ExpandResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", resp, "Failure responding to next results request") + } + return +} + +// ExpandComplete enumerates all values, automatically crossing page boundaries as required. +func (client MsixImagesClient) ExpandComplete(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (result ExpandMsixImageListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MsixImagesClient.Expand") + 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.Expand(ctx, resourceGroupName, hostPoolName, msixImageURI) + return +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msixpackages.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msixpackages.go new file mode 100644 index 000000000000..892c0f7534b1 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/msixpackages.go @@ -0,0 +1,554 @@ +package desktopvirtualization + +// 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" +) + +// MSIXPackagesClient is the client for the MSIXPackages methods of the Desktopvirtualization service. +type MSIXPackagesClient struct { + BaseClient +} + +// NewMSIXPackagesClient creates an instance of the MSIXPackagesClient client. +func NewMSIXPackagesClient(subscriptionID string) MSIXPackagesClient { + return NewMSIXPackagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMSIXPackagesClientWithBaseURI creates an instance of the MSIXPackagesClient 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 NewMSIXPackagesClientWithBaseURI(baseURI string, subscriptionID string) MSIXPackagesClient { + return MSIXPackagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a MSIX package. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// msixPackageFullName - the version specific package full name of the MSIX package within specified hostpool +// msixPackage - object containing MSIX Package definitions. +func (client MSIXPackagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage MSIXPackage) (result MSIXPackage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: msixPackageFullName, + Constraints: []validation.Constraint{{Target: "msixPackageFullName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "msixPackageFullName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: msixPackage, + Constraints: []validation.Constraint{{Target: "msixPackage.MSIXPackageProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MSIXPackagesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, hostPoolName, msixPackageFullName, msixPackage) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MSIXPackagesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage MSIXPackage) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "msixPackageFullName": autorest.Encode("path", msixPackageFullName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", pathParameters), + autorest.WithJSON(msixPackage), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client MSIXPackagesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MSIXPackagesClient) CreateOrUpdateResponder(resp *http.Response) (result MSIXPackage, 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 remove an MSIX Package. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// msixPackageFullName - the version specific package full name of the MSIX package within specified hostpool +func (client MSIXPackagesClient) Delete(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: msixPackageFullName, + Constraints: []validation.Constraint{{Target: "msixPackageFullName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "msixPackageFullName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MSIXPackagesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, hostPoolName, msixPackageFullName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MSIXPackagesClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "msixPackageFullName": autorest.Encode("path", msixPackageFullName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", 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 MSIXPackagesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MSIXPackagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a msixpackage. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// msixPackageFullName - the version specific package full name of the MSIX package within specified hostpool +func (client MSIXPackagesClient) Get(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (result MSIXPackage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: msixPackageFullName, + Constraints: []validation.Constraint{{Target: "msixPackageFullName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "msixPackageFullName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MSIXPackagesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, hostPoolName, msixPackageFullName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client MSIXPackagesClient) GetPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "msixPackageFullName": autorest.Encode("path", msixPackageFullName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client MSIXPackagesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MSIXPackagesClient) GetResponder(resp *http.Response) (result MSIXPackage, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list MSIX packages in hostpool. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +func (client MSIXPackagesClient) List(ctx context.Context, resourceGroupName string, hostPoolName string) (result MSIXPackageListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.List") + defer func() { + sc := -1 + if result.mpl.Response.Response != nil { + sc = result.mpl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MSIXPackagesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, hostPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.mpl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "List", resp, "Failure sending request") + return + } + + result.mpl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "List", resp, "Failure responding to request") + } + if result.mpl.hasNextLink() && result.mpl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client MSIXPackagesClient) ListPreparer(ctx context.Context, resourceGroupName string, hostPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages", pathParameters), + 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 MSIXPackagesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MSIXPackagesClient) ListResponder(resp *http.Response) (result MSIXPackageList, 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 MSIXPackagesClient) listNextResults(ctx context.Context, lastResults MSIXPackageList) (result MSIXPackageList, err error) { + req, err := lastResults.mSIXPackageListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "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, "desktopvirtualization.MSIXPackagesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client MSIXPackagesClient) ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string) (result MSIXPackageListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.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, resourceGroupName, hostPoolName) + return +} + +// Update update an MSIX Package. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// msixPackageFullName - the version specific package full name of the MSIX package within specified hostpool +// msixPackage - object containing MSIX Package definitions. +func (client MSIXPackagesClient) Update(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage *MSIXPackagePatch) (result MSIXPackage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MSIXPackagesClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: msixPackageFullName, + Constraints: []validation.Constraint{{Target: "msixPackageFullName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "msixPackageFullName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.MSIXPackagesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, hostPoolName, msixPackageFullName, msixPackage) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.MSIXPackagesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MSIXPackagesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixPackageFullName string, msixPackage *MSIXPackagePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "msixPackageFullName": autorest.Encode("path", msixPackageFullName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if msixPackage != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(msixPackage)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client MSIXPackagesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MSIXPackagesClient) UpdateResponder(resp *http.Response) (result MSIXPackage, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/operations.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/operations.go new file mode 100644 index 000000000000..de983d6e97af --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/operations.go @@ -0,0 +1,108 @@ +package desktopvirtualization + +// 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 client for the Operations methods of the Desktopvirtualization service. +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 list all of the available operations the Desktop Virtualization resource provider supports. +func (client OperationsClient) List(ctx context.Context) (result ResourceProviderOperationList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DesktopVirtualization/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 ResourceProviderOperationList, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/sessionhosts.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/sessionhosts.go new file mode 100644 index 000000000000..f35424b343b9 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/sessionhosts.go @@ -0,0 +1,460 @@ +package desktopvirtualization + +// 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" +) + +// SessionHostsClient is the client for the SessionHosts methods of the Desktopvirtualization service. +type SessionHostsClient struct { + BaseClient +} + +// NewSessionHostsClient creates an instance of the SessionHostsClient client. +func NewSessionHostsClient(subscriptionID string) SessionHostsClient { + return NewSessionHostsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSessionHostsClientWithBaseURI creates an instance of the SessionHostsClient 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 NewSessionHostsClientWithBaseURI(baseURI string, subscriptionID string) SessionHostsClient { + return SessionHostsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete remove a SessionHost. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// force - force flag to force sessionHost deletion even when userSession exists. +func (client SessionHostsClient) Delete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, force *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.SessionHostsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, force) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SessionHostsClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, force *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if force != nil { + queryParameters["force"] = autorest.Encode("query", *force) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", 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 SessionHostsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SessionHostsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a session host. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +func (client SessionHostsClient) Get(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result SessionHost, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.SessionHostsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, hostPoolName, sessionHostName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SessionHostsClient) GetPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SessionHostsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SessionHostsClient) GetResponder(resp *http.Response) (result SessionHost, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list sessionHosts. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +func (client SessionHostsClient) List(ctx context.Context, resourceGroupName string, hostPoolName string) (result SessionHostListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostsClient.List") + defer func() { + sc := -1 + if result.shl.Response.Response != nil { + sc = result.shl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.SessionHostsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, hostPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.shl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "List", resp, "Failure sending request") + return + } + + result.shl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "List", resp, "Failure responding to request") + } + if result.shl.hasNextLink() && result.shl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SessionHostsClient) ListPreparer(ctx context.Context, resourceGroupName string, hostPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts", pathParameters), + 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 SessionHostsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SessionHostsClient) ListResponder(resp *http.Response) (result SessionHostList, 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 SessionHostsClient) listNextResults(ctx context.Context, lastResults SessionHostList) (result SessionHostList, err error) { + req, err := lastResults.sessionHostListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "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, "desktopvirtualization.SessionHostsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SessionHostsClient) ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string) (result SessionHostListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostsClient.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, resourceGroupName, hostPoolName) + return +} + +// Update update a session host. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// sessionHost - object containing SessionHost definitions. +func (client SessionHostsClient) Update(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, sessionHost *SessionHostPatch) (result SessionHost, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SessionHostsClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.SessionHostsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, sessionHost) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.SessionHostsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SessionHostsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, sessionHost *SessionHostPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if sessionHost != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(sessionHost)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SessionHostsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SessionHostsClient) UpdateResponder(resp *http.Response) (result SessionHost, 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/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/startmenuitems.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/startmenuitems.go new file mode 100644 index 000000000000..ddf7ddc9ab5c --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/startmenuitems.go @@ -0,0 +1,172 @@ +package desktopvirtualization + +// 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" +) + +// StartMenuItemsClient is the client for the StartMenuItems methods of the Desktopvirtualization service. +type StartMenuItemsClient struct { + BaseClient +} + +// NewStartMenuItemsClient creates an instance of the StartMenuItemsClient client. +func NewStartMenuItemsClient(subscriptionID string) StartMenuItemsClient { + return NewStartMenuItemsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStartMenuItemsClientWithBaseURI creates an instance of the StartMenuItemsClient 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 NewStartMenuItemsClientWithBaseURI(baseURI string, subscriptionID string) StartMenuItemsClient { + return StartMenuItemsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list start menu items in the given application group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// applicationGroupName - the name of the application group +func (client StartMenuItemsClient) List(ctx context.Context, resourceGroupName string, applicationGroupName string) (result StartMenuItemListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StartMenuItemsClient.List") + defer func() { + sc := -1 + if result.smil.Response.Response != nil { + sc = result.smil.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: applicationGroupName, + Constraints: []validation.Constraint{{Target: "applicationGroupName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "applicationGroupName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.StartMenuItemsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, applicationGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.StartMenuItemsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.smil.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.StartMenuItemsClient", "List", resp, "Failure sending request") + return + } + + result.smil, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.StartMenuItemsClient", "List", resp, "Failure responding to request") + } + if result.smil.hasNextLink() && result.smil.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client StartMenuItemsClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationGroupName": autorest.Encode("path", applicationGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems", pathParameters), + 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 StartMenuItemsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client StartMenuItemsClient) ListResponder(resp *http.Response) (result StartMenuItemList, 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 StartMenuItemsClient) listNextResults(ctx context.Context, lastResults StartMenuItemList) (result StartMenuItemList, err error) { + req, err := lastResults.startMenuItemListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.StartMenuItemsClient", "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, "desktopvirtualization.StartMenuItemsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.StartMenuItemsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client StartMenuItemsClient) ListComplete(ctx context.Context, resourceGroupName string, applicationGroupName string) (result StartMenuItemListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StartMenuItemsClient.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, resourceGroupName, applicationGroupName) + return +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/usersessions.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/usersessions.go new file mode 100644 index 000000000000..2d5206be9ff6 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/usersessions.go @@ -0,0 +1,709 @@ +package desktopvirtualization + +// 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" +) + +// UserSessionsClient is the client for the UserSessions methods of the Desktopvirtualization service. +type UserSessionsClient struct { + BaseClient +} + +// NewUserSessionsClient creates an instance of the UserSessionsClient client. +func NewUserSessionsClient(subscriptionID string) UserSessionsClient { + return NewUserSessionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserSessionsClientWithBaseURI creates an instance of the UserSessionsClient 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 NewUserSessionsClientWithBaseURI(baseURI string, subscriptionID string) UserSessionsClient { + return UserSessionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete remove a userSession. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// userSessionID - the name of the user session within the specified session host +// force - force flag to login off userSession. +func (client UserSessionsClient) Delete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, force *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: userSessionID, + Constraints: []validation.Constraint{{Target: "userSessionID", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "userSessionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, userSessionID, force) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client UserSessionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, force *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userSessionId": autorest.Encode("path", userSessionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if force != nil { + queryParameters["force"] = autorest.Encode("query", *force) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}", 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 UserSessionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Disconnect disconnect a userSession. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// userSessionID - the name of the user session within the specified session host +func (client UserSessionsClient) Disconnect(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.Disconnect") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: userSessionID, + Constraints: []validation.Constraint{{Target: "userSessionID", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "userSessionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "Disconnect", err.Error()) + } + + req, err := client.DisconnectPreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, userSessionID) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Disconnect", nil, "Failure preparing request") + return + } + + resp, err := client.DisconnectSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Disconnect", resp, "Failure sending request") + return + } + + result, err = client.DisconnectResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Disconnect", resp, "Failure responding to request") + } + + return +} + +// DisconnectPreparer prepares the Disconnect request. +func (client UserSessionsClient) DisconnectPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userSessionId": autorest.Encode("path", userSessionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisconnectSender sends the Disconnect request. The method will close the +// http.Response Body if it receives an error. +func (client UserSessionsClient) DisconnectSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisconnectResponder handles the response to the Disconnect request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) DisconnectResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a userSession. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// userSessionID - the name of the user session within the specified session host +func (client UserSessionsClient) Get(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (result UserSession, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: userSessionID, + Constraints: []validation.Constraint{{Target: "userSessionID", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "userSessionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, userSessionID) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client UserSessionsClient) GetPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userSessionId": autorest.Encode("path", userSessionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client UserSessionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) GetResponder(resp *http.Response) (result UserSession, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list userSessions. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +func (client UserSessionsClient) List(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result UserSessionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.List") + defer func() { + sc := -1 + if result.usl.Response.Response != nil { + sc = result.usl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, hostPoolName, sessionHostName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.usl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "List", resp, "Failure sending request") + return + } + + result.usl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "List", resp, "Failure responding to request") + } + if result.usl.hasNextLink() && result.usl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client UserSessionsClient) ListPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions", pathParameters), + 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 UserSessionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) ListResponder(resp *http.Response) (result UserSessionList, 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 UserSessionsClient) listNextResults(ctx context.Context, lastResults UserSessionList) (result UserSessionList, err error) { + req, err := lastResults.userSessionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "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, "desktopvirtualization.UserSessionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserSessionsClient) ListComplete(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string) (result UserSessionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.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, resourceGroupName, hostPoolName, sessionHostName) + return +} + +// ListByHostPool list userSessions. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// filter - oData filter expression. Valid properties for filtering are userprincipalname and sessionstate. +func (client UserSessionsClient) ListByHostPool(ctx context.Context, resourceGroupName string, hostPoolName string, filter string) (result UserSessionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.ListByHostPool") + defer func() { + sc := -1 + if result.usl.Response.Response != nil { + sc = result.usl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "ListByHostPool", err.Error()) + } + + result.fn = client.listByHostPoolNextResults + req, err := client.ListByHostPoolPreparer(ctx, resourceGroupName, hostPoolName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "ListByHostPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHostPoolSender(req) + if err != nil { + result.usl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "ListByHostPool", resp, "Failure sending request") + return + } + + result.usl, err = client.ListByHostPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "ListByHostPool", resp, "Failure responding to request") + } + if result.usl.hasNextLink() && result.usl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHostPoolPreparer prepares the ListByHostPool request. +func (client UserSessionsClient) ListByHostPoolPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHostPoolSender sends the ListByHostPool request. The method will close the +// http.Response Body if it receives an error. +func (client UserSessionsClient) ListByHostPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHostPoolResponder handles the response to the ListByHostPool request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) ListByHostPoolResponder(resp *http.Response) (result UserSessionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHostPoolNextResults retrieves the next set of results, if any. +func (client UserSessionsClient) listByHostPoolNextResults(ctx context.Context, lastResults UserSessionList) (result UserSessionList, err error) { + req, err := lastResults.userSessionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "listByHostPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHostPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "listByHostPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHostPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "listByHostPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHostPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserSessionsClient) ListByHostPoolComplete(ctx context.Context, resourceGroupName string, hostPoolName string, filter string) (result UserSessionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.ListByHostPool") + 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.ListByHostPool(ctx, resourceGroupName, hostPoolName, filter) + return +} + +// SendMessageMethod send a message to a user. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// hostPoolName - the name of the host pool within the specified resource group +// sessionHostName - the name of the session host within the specified host pool +// userSessionID - the name of the user session within the specified session host +// sendMessage - object containing message includes title and message body +func (client UserSessionsClient) SendMessageMethod(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, sendMessage *SendMessage) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSessionsClient.SendMessageMethod") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: hostPoolName, + Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: sessionHostName, + Constraints: []validation.Constraint{{Target: "sessionHostName", Name: validation.MaxLength, Rule: 48, Chain: nil}, + {Target: "sessionHostName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: userSessionID, + Constraints: []validation.Constraint{{Target: "userSessionID", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "userSessionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.UserSessionsClient", "SendMessageMethod", err.Error()) + } + + req, err := client.SendMessageMethodPreparer(ctx, resourceGroupName, hostPoolName, sessionHostName, userSessionID, sendMessage) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "SendMessageMethod", nil, "Failure preparing request") + return + } + + resp, err := client.SendMessageMethodSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "SendMessageMethod", resp, "Failure sending request") + return + } + + result, err = client.SendMessageMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.UserSessionsClient", "SendMessageMethod", resp, "Failure responding to request") + } + + return +} + +// SendMessageMethodPreparer prepares the SendMessageMethod request. +func (client UserSessionsClient) SendMessageMethodPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, sessionHostName string, userSessionID string, sendMessage *SendMessage) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hostPoolName": autorest.Encode("path", hostPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sessionHostName": autorest.Encode("path", sessionHostName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userSessionId": autorest.Encode("path", userSessionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if sendMessage != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(sendMessage)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SendMessageMethodSender sends the SendMessageMethod request. The method will close the +// http.Response Body if it receives an error. +func (client UserSessionsClient) SendMessageMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// SendMessageMethodResponder handles the response to the SendMessageMethod request. The method always +// closes the http.Response Body. +func (client UserSessionsClient) SendMessageMethodResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/version.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/version.go new file mode 100644 index 000000000000..e15a95ed5717 --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/version.go @@ -0,0 +1,30 @@ +package desktopvirtualization + +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() + " desktopvirtualization/2020-10-19-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/workspaces.go b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/workspaces.go new file mode 100644 index 000000000000..6b28d0c4403b --- /dev/null +++ b/services/preview/desktopvirtualization/mgmt/2020-10-19-preview/desktopvirtualization/workspaces.go @@ -0,0 +1,644 @@ +package desktopvirtualization + +// 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" +) + +// WorkspacesClient is the client for the Workspaces methods of the Desktopvirtualization service. +type WorkspacesClient struct { + BaseClient +} + +// NewWorkspacesClient creates an instance of the WorkspacesClient client. +func NewWorkspacesClient(subscriptionID string) WorkspacesClient { + return NewWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkspacesClientWithBaseURI creates an instance of the WorkspacesClient 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 NewWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) WorkspacesClient { + return WorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a workspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// workspaceName - the name of the workspace +// workspace - object containing Workspace definitions. +func (client WorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace) (result Workspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.WorkspacesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, workspace) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/workspaces/{workspaceName}", pathParameters), + autorest.WithJSON(workspace), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result Workspace, 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 remove a workspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// workspaceName - the name of the workspace +func (client WorkspacesClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.WorkspacesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/workspaces/{workspaceName}", 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 WorkspacesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a workspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// workspaceName - the name of the workspace +func (client WorkspacesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string) (result Workspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.WorkspacesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/workspaces/{workspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) GetResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list workspaces. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client WorkspacesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result WorkspaceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.wl.Response.Response != nil { + sc = result.wl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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("desktopvirtualization.WorkspacesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.wl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.wl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.wl.hasNextLink() && result.wl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WorkspacesClient) 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-10-19-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.DesktopVirtualization/workspaces", 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 WorkspacesClient) 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 WorkspacesClient) ListByResourceGroupResponder(resp *http.Response) (result WorkspaceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client WorkspacesClient) listByResourceGroupNextResults(ctx context.Context, lastResults WorkspaceList) (result WorkspaceList, err error) { + req, err := lastResults.workspaceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result WorkspaceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription list workspaces in subscription. +func (client WorkspacesClient) ListBySubscription(ctx context.Context) (result WorkspaceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListBySubscription") + defer func() { + sc := -1 + if result.wl.Response.Response != nil { + sc = result.wl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.WorkspacesClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.wl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.wl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.wl.hasNextLink() && result.wl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client WorkspacesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-19-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces", 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 WorkspacesClient) 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 WorkspacesClient) ListBySubscriptionResponder(resp *http.Response) (result WorkspaceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client WorkspacesClient) listBySubscriptionNextResults(ctx context.Context, lastResults WorkspaceList) (result WorkspaceList, err error) { + req, err := lastResults.workspaceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkspacesClient) ListBySubscriptionComplete(ctx context.Context) (result WorkspaceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListBySubscription") + 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.ListBySubscription(ctx) + return +} + +// Update update a workspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// workspaceName - the name of the workspace +// workspace - object containing Workspace definitions. +func (client WorkspacesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, workspace *WorkspacePatch) (result Workspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.Update") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("desktopvirtualization.WorkspacesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, workspaceName, workspace) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "desktopvirtualization.WorkspacesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkspacesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, workspace *WorkspacePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2020-10-19-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.DesktopVirtualization/workspaces/{workspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if workspace != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(workspace)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) UpdateResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}