/
zz_generated_global_client.go
221 lines (205 loc) · 9.91 KB
/
zz_generated_global_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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//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 armweb
import (
"context"
"errors"
"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"
"net/url"
"strings"
)
// GlobalClient contains the methods for the Global group.
// Don't use this type directly, use NewGlobalClient() instead.
type GlobalClient struct {
ep string
pl runtime.Pipeline
subscriptionID string
}
// NewGlobalClient creates a new instance of GlobalClient with the specified values.
func NewGlobalClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GlobalClient {
cp := arm.ClientOptions{}
if options != nil {
cp = *options
}
if len(cp.Host) == 0 {
cp.Host = arm.AzurePublicCloud
}
return &GlobalClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
}
// GetDeletedWebApp - Description for Get deleted app for a subscription.
// If the operation fails it returns the *DefaultErrorResponse error type.
func (client *GlobalClient) GetDeletedWebApp(ctx context.Context, deletedSiteID string, options *GlobalGetDeletedWebAppOptions) (GlobalGetDeletedWebAppResponse, error) {
req, err := client.getDeletedWebAppCreateRequest(ctx, deletedSiteID, options)
if err != nil {
return GlobalGetDeletedWebAppResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return GlobalGetDeletedWebAppResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return GlobalGetDeletedWebAppResponse{}, client.getDeletedWebAppHandleError(resp)
}
return client.getDeletedWebAppHandleResponse(resp)
}
// getDeletedWebAppCreateRequest creates the GetDeletedWebApp request.
func (client *GlobalClient) getDeletedWebAppCreateRequest(ctx context.Context, deletedSiteID string, options *GlobalGetDeletedWebAppOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Web/deletedSites/{deletedSiteId}"
if deletedSiteID == "" {
return nil, errors.New("parameter deletedSiteID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deletedSiteId}", url.PathEscape(deletedSiteID))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-02-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// getDeletedWebAppHandleResponse handles the GetDeletedWebApp response.
func (client *GlobalClient) getDeletedWebAppHandleResponse(resp *http.Response) (GlobalGetDeletedWebAppResponse, error) {
result := GlobalGetDeletedWebAppResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.DeletedSite); err != nil {
return GlobalGetDeletedWebAppResponse{}, runtime.NewResponseError(err, resp)
}
return result, nil
}
// getDeletedWebAppHandleError handles the GetDeletedWebApp error response.
func (client *GlobalClient) getDeletedWebAppHandleError(resp *http.Response) error {
body, err := runtime.Payload(resp)
if err != nil {
return runtime.NewResponseError(err, resp)
}
errType := DefaultErrorResponse{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)
}
// GetDeletedWebAppSnapshots - Description for Get all deleted apps for a subscription.
// If the operation fails it returns the *DefaultErrorResponse error type.
func (client *GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, deletedSiteID string, options *GlobalGetDeletedWebAppSnapshotsOptions) (GlobalGetDeletedWebAppSnapshotsResponse, error) {
req, err := client.getDeletedWebAppSnapshotsCreateRequest(ctx, deletedSiteID, options)
if err != nil {
return GlobalGetDeletedWebAppSnapshotsResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return GlobalGetDeletedWebAppSnapshotsResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return GlobalGetDeletedWebAppSnapshotsResponse{}, client.getDeletedWebAppSnapshotsHandleError(resp)
}
return client.getDeletedWebAppSnapshotsHandleResponse(resp)
}
// getDeletedWebAppSnapshotsCreateRequest creates the GetDeletedWebAppSnapshots request.
func (client *GlobalClient) getDeletedWebAppSnapshotsCreateRequest(ctx context.Context, deletedSiteID string, options *GlobalGetDeletedWebAppSnapshotsOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Web/deletedSites/{deletedSiteId}/snapshots"
if deletedSiteID == "" {
return nil, errors.New("parameter deletedSiteID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deletedSiteId}", url.PathEscape(deletedSiteID))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-02-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// getDeletedWebAppSnapshotsHandleResponse handles the GetDeletedWebAppSnapshots response.
func (client *GlobalClient) getDeletedWebAppSnapshotsHandleResponse(resp *http.Response) (GlobalGetDeletedWebAppSnapshotsResponse, error) {
result := GlobalGetDeletedWebAppSnapshotsResponse{RawResponse: resp}
if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotArray); err != nil {
return GlobalGetDeletedWebAppSnapshotsResponse{}, runtime.NewResponseError(err, resp)
}
return result, nil
}
// getDeletedWebAppSnapshotsHandleError handles the GetDeletedWebAppSnapshots error response.
func (client *GlobalClient) getDeletedWebAppSnapshotsHandleError(resp *http.Response) error {
body, err := runtime.Payload(resp)
if err != nil {
return runtime.NewResponseError(err, resp)
}
errType := DefaultErrorResponse{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)
}
// GetSubscriptionOperationWithAsyncResponse - Description for Gets an operation in a subscription and given region
// If the operation fails it returns the *DefaultErrorResponse error type.
func (client *GlobalClient) GetSubscriptionOperationWithAsyncResponse(ctx context.Context, location string, operationID string, options *GlobalGetSubscriptionOperationWithAsyncResponseOptions) (GlobalGetSubscriptionOperationWithAsyncResponseResponse, error) {
req, err := client.getSubscriptionOperationWithAsyncResponseCreateRequest(ctx, location, operationID, options)
if err != nil {
return GlobalGetSubscriptionOperationWithAsyncResponseResponse{}, err
}
resp, err := client.pl.Do(req)
if err != nil {
return GlobalGetSubscriptionOperationWithAsyncResponseResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusNoContent) {
return GlobalGetSubscriptionOperationWithAsyncResponseResponse{}, client.getSubscriptionOperationWithAsyncResponseHandleError(resp)
}
return GlobalGetSubscriptionOperationWithAsyncResponseResponse{RawResponse: resp}, nil
}
// getSubscriptionOperationWithAsyncResponseCreateRequest creates the GetSubscriptionOperationWithAsyncResponse request.
func (client *GlobalClient) getSubscriptionOperationWithAsyncResponseCreateRequest(ctx context.Context, location string, operationID string, options *GlobalGetSubscriptionOperationWithAsyncResponseOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/operations/{operationId}"
if location == "" {
return nil, errors.New("parameter location cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
if operationID == "" {
return nil, errors.New("parameter operationID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2021-02-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header.Set("Accept", "application/json")
return req, nil
}
// getSubscriptionOperationWithAsyncResponseHandleError handles the GetSubscriptionOperationWithAsyncResponse error response.
func (client *GlobalClient) getSubscriptionOperationWithAsyncResponseHandleError(resp *http.Response) error {
body, err := runtime.Payload(resp)
if err != nil {
return runtime.NewResponseError(err, resp)
}
errType := DefaultErrorResponse{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)
}