...
1 package qnamaker
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 type OperationsClient struct {
19 BaseClient
20 }
21
22
23 func NewOperationsClient(endpoint string) OperationsClient {
24 return OperationsClient{New(endpoint)}
25 }
26
27
28
29
30 func (client OperationsClient) GetDetails(ctx context.Context, operationID string) (result Operation, err error) {
31 if tracing.IsEnabled() {
32 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.GetDetails")
33 defer func() {
34 sc := -1
35 if result.Response.Response != nil {
36 sc = result.Response.Response.StatusCode
37 }
38 tracing.EndSpan(ctx, sc, err)
39 }()
40 }
41 req, err := client.GetDetailsPreparer(ctx, operationID)
42 if err != nil {
43 err = autorest.NewErrorWithError(err, "qnamaker.OperationsClient", "GetDetails", nil, "Failure preparing request")
44 return
45 }
46
47 resp, err := client.GetDetailsSender(req)
48 if err != nil {
49 result.Response = autorest.Response{Response: resp}
50 err = autorest.NewErrorWithError(err, "qnamaker.OperationsClient", "GetDetails", resp, "Failure sending request")
51 return
52 }
53
54 result, err = client.GetDetailsResponder(resp)
55 if err != nil {
56 err = autorest.NewErrorWithError(err, "qnamaker.OperationsClient", "GetDetails", resp, "Failure responding to request")
57 return
58 }
59
60 return
61 }
62
63
64 func (client OperationsClient) GetDetailsPreparer(ctx context.Context, operationID string) (*http.Request, error) {
65 urlParameters := map[string]interface{}{
66 "Endpoint": client.Endpoint,
67 }
68
69 pathParameters := map[string]interface{}{
70 "operationId": autorest.Encode("path", operationID),
71 }
72
73 preparer := autorest.CreatePreparer(
74 autorest.AsGet(),
75 autorest.WithCustomBaseURL("{Endpoint}/qnamaker/v5.0-preview.1", urlParameters),
76 autorest.WithPathParameters("/operations/{operationId}", pathParameters))
77 return preparer.Prepare((&http.Request{}).WithContext(ctx))
78 }
79
80
81
82 func (client OperationsClient) GetDetailsSender(req *http.Request) (*http.Response, error) {
83 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
84 }
85
86
87
88 func (client OperationsClient) GetDetailsResponder(resp *http.Response) (result Operation, err error) {
89 err = autorest.Respond(
90 resp,
91 azure.WithErrorUnlessStatusCode(http.StatusOK),
92 autorest.ByUnmarshallingJSON(&result),
93 autorest.ByClosing())
94 result.Response = autorest.Response{Response: resp}
95 return
96 }
97
View as plain text