-
Notifications
You must be signed in to change notification settings - Fork 797
/
zz_generated_operations_client.go
89 lines (80 loc) · 3.33 KB
/
zz_generated_operations_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//go:build go1.16
// +build go1.16
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
package armdesktopvirtualization
import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"net/http"
)
// OperationsClient contains the methods for the Operations group.
// Don't use this type directly, use NewOperationsClient() instead.
type OperationsClient struct {
ep string
pl runtime.Pipeline
}
// NewOperationsClient creates a new instance of OperationsClient with the specified values.
func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient {
cp := arm.ClientOptions{}
if options != nil {
cp = *options
}
if len(cp.Host) == 0 {
cp.Host = arm.AzurePublicCloud
}
return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
}
// List - List all of the available operations the Desktop Virtualization resource provider supports.
// If the operation fails it returns the *CloudError error type.
func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager {
return &OperationsListPager{
client: client,
requester: func(ctx context.Context) (*policy.Request, error) {
return client.listCreateRequest(ctx, options)
},
advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) {
return runtime.NewRequest(ctx, http.MethodGet, *resp.ResourceProviderOperationList.NextLink)
},
}
}
// listCreateRequest creates the List request.
func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) {
urlPath := "/providers/Microsoft.DesktopVirtualization/operations"
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-09-03-preview")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// listHandleResponse handles the List response.
func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) {
result := OperationsListResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.ResourceProviderOperationList); err != nil {
return OperationsListResponse{}, runtime.NewResponseError(err, resp)
}
return result, nil
}
// listHandleError handles the List error response.
func (client *OperationsClient) listHandleError(resp *http.Response) error {
body, err := runtime.Payload(resp)
if err != nil {
return runtime.NewResponseError(err, resp)
}
errType := CloudError{raw: string(body)}
if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil {
return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp)
}
return runtime.NewResponseError(&errType, resp)
}