...
1 package workspaces
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/tracing"
14 "net/http"
15 )
16
17
18
19 type OperationsClient struct {
20 BaseClient
21 }
22
23
24 func NewOperationsClient(subscriptionID string) OperationsClient {
25 return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
31 return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35 func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) {
36 if tracing.IsEnabled() {
37 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
38 defer func() {
39 sc := -1
40 if result.Response.Response != nil {
41 sc = result.Response.Response.StatusCode
42 }
43 tracing.EndSpan(ctx, sc, err)
44 }()
45 }
46 req, err := client.ListPreparer(ctx)
47 if err != nil {
48 err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", nil, "Failure preparing request")
49 return
50 }
51
52 resp, err := client.ListSender(req)
53 if err != nil {
54 result.Response = autorest.Response{Response: resp}
55 err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", resp, "Failure sending request")
56 return
57 }
58
59 result, err = client.ListResponder(resp)
60 if err != nil {
61 err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", resp, "Failure responding to request")
62 return
63 }
64
65 return
66 }
67
68
69 func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
70 const APIVersion = "2019-10-01"
71 queryParameters := map[string]interface{}{
72 "api-version": APIVersion,
73 }
74
75 preparer := autorest.CreatePreparer(
76 autorest.AsGet(),
77 autorest.WithBaseURL(client.BaseURI),
78 autorest.WithPath("/providers/Microsoft.MachineLearning/operations"),
79 autorest.WithQueryParameters(queryParameters))
80 return preparer.Prepare((&http.Request{}).WithContext(ctx))
81 }
82
83
84
85 func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
86 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
87 }
88
89
90
91 func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
92 err = autorest.Respond(
93 resp,
94 azure.WithErrorUnlessStatusCode(http.StatusOK),
95 autorest.ByUnmarshallingJSON(&result),
96 autorest.ByClosing())
97 result.Response = autorest.Response{Response: resp}
98 return
99 }
100
View as plain text