1package desktopvirtualization 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// MsixImagesClient is the client for the MsixImages methods of the Desktopvirtualization service. 19type MsixImagesClient struct { 20 BaseClient 21} 22 23// NewMsixImagesClient creates an instance of the MsixImagesClient client. 24func NewMsixImagesClient(subscriptionID string) MsixImagesClient { 25 return NewMsixImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewMsixImagesClientWithBaseURI creates an instance of the MsixImagesClient client using a custom endpoint. Use this 29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewMsixImagesClientWithBaseURI(baseURI string, subscriptionID string) MsixImagesClient { 31 return MsixImagesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Expand expands and Lists MSIX packages in an Image, given the Image Path. 35// Parameters: 36// resourceGroupName - the name of the resource group. The name is case insensitive. 37// hostPoolName - the name of the host pool within the specified resource group 38// msixImageURI - object containing URI to MSIX Image 39func (client MsixImagesClient) Expand(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (result ExpandMsixImageListPage, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/MsixImagesClient.Expand") 42 defer func() { 43 sc := -1 44 if result.emil.Response.Response != nil { 45 sc = result.emil.Response.Response.StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 if err := validation.Validate([]validation.Validation{ 51 {TargetValue: client.SubscriptionID, 52 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 53 {TargetValue: resourceGroupName, 54 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 55 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 57 {TargetValue: hostPoolName, 58 Constraints: []validation.Constraint{{Target: "hostPoolName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 59 {Target: "hostPoolName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { 60 return result, validation.NewError("desktopvirtualization.MsixImagesClient", "Expand", err.Error()) 61 } 62 63 result.fn = client.expandNextResults 64 req, err := client.ExpandPreparer(ctx, resourceGroupName, hostPoolName, msixImageURI) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", nil, "Failure preparing request") 67 return 68 } 69 70 resp, err := client.ExpandSender(req) 71 if err != nil { 72 result.emil.Response = autorest.Response{Response: resp} 73 err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", resp, "Failure sending request") 74 return 75 } 76 77 result.emil, err = client.ExpandResponder(resp) 78 if err != nil { 79 err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "Expand", resp, "Failure responding to request") 80 return 81 } 82 if result.emil.hasNextLink() && result.emil.IsEmpty() { 83 err = result.NextWithContext(ctx) 84 return 85 } 86 87 return 88} 89 90// ExpandPreparer prepares the Expand request. 91func (client MsixImagesClient) ExpandPreparer(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 93 "hostPoolName": autorest.Encode("path", hostPoolName), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 } 97 98 const APIVersion = "2020-09-21-preview" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 103 preparer := autorest.CreatePreparer( 104 autorest.AsContentType("application/json; charset=utf-8"), 105 autorest.AsPost(), 106 autorest.WithBaseURL(client.BaseURI), 107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage", pathParameters), 108 autorest.WithJSON(msixImageURI), 109 autorest.WithQueryParameters(queryParameters)) 110 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 111} 112 113// ExpandSender sends the Expand request. The method will close the 114// http.Response Body if it receives an error. 115func (client MsixImagesClient) ExpandSender(req *http.Request) (*http.Response, error) { 116 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 117} 118 119// ExpandResponder handles the response to the Expand request. The method always 120// closes the http.Response Body. 121func (client MsixImagesClient) ExpandResponder(resp *http.Response) (result ExpandMsixImageList, err error) { 122 err = autorest.Respond( 123 resp, 124 azure.WithErrorUnlessStatusCode(http.StatusOK), 125 autorest.ByUnmarshallingJSON(&result), 126 autorest.ByClosing()) 127 result.Response = autorest.Response{Response: resp} 128 return 129} 130 131// expandNextResults retrieves the next set of results, if any. 132func (client MsixImagesClient) expandNextResults(ctx context.Context, lastResults ExpandMsixImageList) (result ExpandMsixImageList, err error) { 133 req, err := lastResults.expandMsixImageListPreparer(ctx) 134 if err != nil { 135 return result, autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", nil, "Failure preparing next results request") 136 } 137 if req == nil { 138 return 139 } 140 resp, err := client.ExpandSender(req) 141 if err != nil { 142 result.Response = autorest.Response{Response: resp} 143 return result, autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", resp, "Failure sending next results request") 144 } 145 result, err = client.ExpandResponder(resp) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "desktopvirtualization.MsixImagesClient", "expandNextResults", resp, "Failure responding to next results request") 148 } 149 return 150} 151 152// ExpandComplete enumerates all values, automatically crossing page boundaries as required. 153func (client MsixImagesClient) ExpandComplete(ctx context.Context, resourceGroupName string, hostPoolName string, msixImageURI MSIXImageURI) (result ExpandMsixImageListIterator, err error) { 154 if tracing.IsEnabled() { 155 ctx = tracing.StartSpan(ctx, fqdn+"/MsixImagesClient.Expand") 156 defer func() { 157 sc := -1 158 if result.Response().Response.Response != nil { 159 sc = result.page.Response().Response.Response.StatusCode 160 } 161 tracing.EndSpan(ctx, sc, err) 162 }() 163 } 164 result.page, err = client.Expand(ctx, resourceGroupName, hostPoolName, msixImageURI) 165 return 166} 167