1 package media
2
3
4
5
6
7
8
9 import (
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
19 type PrivateEndpointConnectionsClient struct {
20 BaseClient
21 }
22
23
24 func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient {
25 return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient {
32 return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40 func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, name string, parameters PrivateEndpointConnection) (result PrivateEndpointConnection, err error) {
41 if tracing.IsEnabled() {
42 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate")
43 defer func() {
44 sc := -1
45 if result.Response.Response != nil {
46 sc = result.Response.Response.StatusCode
47 }
48 tracing.EndSpan(ctx, sc, err)
49 }()
50 }
51 if err := validation.Validate([]validation.Validation{
52 {TargetValue: parameters,
53 Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false,
54 Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
55 return result, validation.NewError("media.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error())
56 }
57
58 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, name, parameters)
59 if err != nil {
60 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request")
61 return
62 }
63
64 resp, err := client.CreateOrUpdateSender(req)
65 if err != nil {
66 result.Response = autorest.Response{Response: resp}
67 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure sending request")
68 return
69 }
70
71 result, err = client.CreateOrUpdateResponder(resp)
72 if err != nil {
73 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request")
74 return
75 }
76
77 return
78 }
79
80
81 func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, name string, parameters PrivateEndpointConnection) (*http.Request, error) {
82 pathParameters := map[string]interface{}{
83 "accountName": autorest.Encode("path", accountName),
84 "name": autorest.Encode("path", name),
85 "resourceGroupName": autorest.Encode("path", resourceGroupName),
86 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
87 }
88
89 const APIVersion = "2020-05-01"
90 queryParameters := map[string]interface{}{
91 "api-version": APIVersion,
92 }
93
94 preparer := autorest.CreatePreparer(
95 autorest.AsContentType("application/json; charset=utf-8"),
96 autorest.AsPut(),
97 autorest.WithBaseURL(client.BaseURI),
98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", pathParameters),
99 autorest.WithJSON(parameters),
100 autorest.WithQueryParameters(queryParameters))
101 return preparer.Prepare((&http.Request{}).WithContext(ctx))
102 }
103
104
105
106 func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
107 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
108 }
109
110
111
112 func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) {
113 err = autorest.Respond(
114 resp,
115 azure.WithErrorUnlessStatusCode(http.StatusOK),
116 autorest.ByUnmarshallingJSON(&result),
117 autorest.ByClosing())
118 result.Response = autorest.Response{Response: resp}
119 return
120 }
121
122
123
124
125
126 func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, name string) (result autorest.Response, err error) {
127 if tracing.IsEnabled() {
128 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete")
129 defer func() {
130 sc := -1
131 if result.Response != nil {
132 sc = result.Response.StatusCode
133 }
134 tracing.EndSpan(ctx, sc, err)
135 }()
136 }
137 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, name)
138 if err != nil {
139 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request")
140 return
141 }
142
143 resp, err := client.DeleteSender(req)
144 if err != nil {
145 result.Response = resp
146 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Delete", resp, "Failure sending request")
147 return
148 }
149
150 result, err = client.DeleteResponder(resp)
151 if err != nil {
152 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Delete", resp, "Failure responding to request")
153 return
154 }
155
156 return
157 }
158
159
160 func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, name string) (*http.Request, error) {
161 pathParameters := map[string]interface{}{
162 "accountName": autorest.Encode("path", accountName),
163 "name": autorest.Encode("path", name),
164 "resourceGroupName": autorest.Encode("path", resourceGroupName),
165 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
166 }
167
168 const APIVersion = "2020-05-01"
169 queryParameters := map[string]interface{}{
170 "api-version": APIVersion,
171 }
172
173 preparer := autorest.CreatePreparer(
174 autorest.AsDelete(),
175 autorest.WithBaseURL(client.BaseURI),
176 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", pathParameters),
177 autorest.WithQueryParameters(queryParameters))
178 return preparer.Prepare((&http.Request{}).WithContext(ctx))
179 }
180
181
182
183 func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (*http.Response, error) {
184 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
185 }
186
187
188
189 func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
190 err = autorest.Respond(
191 resp,
192 azure.WithErrorUnlessStatusCode(http.StatusOK),
193 autorest.ByClosing())
194 result.Response = resp
195 return
196 }
197
198
199
200
201
202 func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string) (result PrivateEndpointConnection, err error) {
203 if tracing.IsEnabled() {
204 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get")
205 defer func() {
206 sc := -1
207 if result.Response.Response != nil {
208 sc = result.Response.Response.StatusCode
209 }
210 tracing.EndSpan(ctx, sc, err)
211 }()
212 }
213 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, name)
214 if err != nil {
215 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request")
216 return
217 }
218
219 resp, err := client.GetSender(req)
220 if err != nil {
221 result.Response = autorest.Response{Response: resp}
222 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request")
223 return
224 }
225
226 result, err = client.GetResponder(resp)
227 if err != nil {
228 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request")
229 return
230 }
231
232 return
233 }
234
235
236 func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, name string) (*http.Request, error) {
237 pathParameters := map[string]interface{}{
238 "accountName": autorest.Encode("path", accountName),
239 "name": autorest.Encode("path", name),
240 "resourceGroupName": autorest.Encode("path", resourceGroupName),
241 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
242 }
243
244 const APIVersion = "2020-05-01"
245 queryParameters := map[string]interface{}{
246 "api-version": APIVersion,
247 }
248
249 preparer := autorest.CreatePreparer(
250 autorest.AsGet(),
251 autorest.WithBaseURL(client.BaseURI),
252 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections/{name}", pathParameters),
253 autorest.WithQueryParameters(queryParameters))
254 return preparer.Prepare((&http.Request{}).WithContext(ctx))
255 }
256
257
258
259 func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) {
260 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
261 }
262
263
264
265 func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) {
266 err = autorest.Respond(
267 resp,
268 azure.WithErrorUnlessStatusCode(http.StatusOK),
269 autorest.ByUnmarshallingJSON(&result),
270 autorest.ByClosing())
271 result.Response = autorest.Response{Response: resp}
272 return
273 }
274
275
276
277
278
279 func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result PrivateEndpointConnectionListResult, err error) {
280 if tracing.IsEnabled() {
281 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List")
282 defer func() {
283 sc := -1
284 if result.Response.Response != nil {
285 sc = result.Response.Response.StatusCode
286 }
287 tracing.EndSpan(ctx, sc, err)
288 }()
289 }
290 req, err := client.ListPreparer(ctx, resourceGroupName, accountName)
291 if err != nil {
292 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request")
293 return
294 }
295
296 resp, err := client.ListSender(req)
297 if err != nil {
298 result.Response = autorest.Response{Response: resp}
299 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request")
300 return
301 }
302
303 result, err = client.ListResponder(resp)
304 if err != nil {
305 err = autorest.NewErrorWithError(err, "media.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request")
306 return
307 }
308
309 return
310 }
311
312
313 func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
314 pathParameters := map[string]interface{}{
315 "accountName": autorest.Encode("path", accountName),
316 "resourceGroupName": autorest.Encode("path", resourceGroupName),
317 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
318 }
319
320 const APIVersion = "2020-05-01"
321 queryParameters := map[string]interface{}{
322 "api-version": APIVersion,
323 }
324
325 preparer := autorest.CreatePreparer(
326 autorest.AsGet(),
327 autorest.WithBaseURL(client.BaseURI),
328 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateEndpointConnections", pathParameters),
329 autorest.WithQueryParameters(queryParameters))
330 return preparer.Prepare((&http.Request{}).WithContext(ctx))
331 }
332
333
334
335 func (client PrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) {
336 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
337 }
338
339
340
341 func (client PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) {
342 err = autorest.Respond(
343 resp,
344 azure.WithErrorUnlessStatusCode(http.StatusOK),
345 autorest.ByUnmarshallingJSON(&result),
346 autorest.ByClosing())
347 result.Response = autorest.Response{Response: resp}
348 return
349 }
350
View as plain text