1 package siterecovery
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 TargetComputeSizesClient struct {
19 BaseClient
20 }
21
22
23 func NewTargetComputeSizesClient(subscriptionID string, resourceGroupName string, resourceName string) TargetComputeSizesClient {
24 return NewTargetComputeSizesClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
25 }
26
27
28
29
30 func NewTargetComputeSizesClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) TargetComputeSizesClient {
31 return TargetComputeSizesClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
32 }
33
34
35
36
37
38
39 func (client TargetComputeSizesClient) ListByReplicationProtectedItems(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result TargetComputeSizeCollectionPage, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/TargetComputeSizesClient.ListByReplicationProtectedItems")
42 defer func() {
43 sc := -1
44 if result.tcsc.Response.Response != nil {
45 sc = result.tcsc.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 result.fn = client.listByReplicationProtectedItemsNextResults
51 req, err := client.ListByReplicationProtectedItemsPreparer(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
52 if err != nil {
53 err = autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "ListByReplicationProtectedItems", nil, "Failure preparing request")
54 return
55 }
56
57 resp, err := client.ListByReplicationProtectedItemsSender(req)
58 if err != nil {
59 result.tcsc.Response = autorest.Response{Response: resp}
60 err = autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "ListByReplicationProtectedItems", resp, "Failure sending request")
61 return
62 }
63
64 result.tcsc, err = client.ListByReplicationProtectedItemsResponder(resp)
65 if err != nil {
66 err = autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "ListByReplicationProtectedItems", resp, "Failure responding to request")
67 return
68 }
69 if result.tcsc.hasNextLink() && result.tcsc.IsEmpty() {
70 err = result.NextWithContext(ctx)
71 return
72 }
73
74 return
75 }
76
77
78 func (client TargetComputeSizesClient) ListByReplicationProtectedItemsPreparer(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) {
79 pathParameters := map[string]interface{}{
80 "fabricName": autorest.Encode("path", fabricName),
81 "protectionContainerName": autorest.Encode("path", protectionContainerName),
82 "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName),
83 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
84 "resourceName": autorest.Encode("path", client.ResourceName),
85 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
86 }
87
88 const APIVersion = "2018-01-10"
89 queryParameters := map[string]interface{}{
90 "api-version": APIVersion,
91 }
92
93 preparer := autorest.CreatePreparer(
94 autorest.AsGet(),
95 autorest.WithBaseURL(client.BaseURI),
96 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/targetComputeSizes", pathParameters),
97 autorest.WithQueryParameters(queryParameters))
98 return preparer.Prepare((&http.Request{}).WithContext(ctx))
99 }
100
101
102
103 func (client TargetComputeSizesClient) ListByReplicationProtectedItemsSender(req *http.Request) (*http.Response, error) {
104 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
105 }
106
107
108
109 func (client TargetComputeSizesClient) ListByReplicationProtectedItemsResponder(resp *http.Response) (result TargetComputeSizeCollection, err error) {
110 err = autorest.Respond(
111 resp,
112 azure.WithErrorUnlessStatusCode(http.StatusOK),
113 autorest.ByUnmarshallingJSON(&result),
114 autorest.ByClosing())
115 result.Response = autorest.Response{Response: resp}
116 return
117 }
118
119
120 func (client TargetComputeSizesClient) listByReplicationProtectedItemsNextResults(ctx context.Context, lastResults TargetComputeSizeCollection) (result TargetComputeSizeCollection, err error) {
121 req, err := lastResults.targetComputeSizeCollectionPreparer(ctx)
122 if err != nil {
123 return result, autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "listByReplicationProtectedItemsNextResults", nil, "Failure preparing next results request")
124 }
125 if req == nil {
126 return
127 }
128 resp, err := client.ListByReplicationProtectedItemsSender(req)
129 if err != nil {
130 result.Response = autorest.Response{Response: resp}
131 return result, autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "listByReplicationProtectedItemsNextResults", resp, "Failure sending next results request")
132 }
133 result, err = client.ListByReplicationProtectedItemsResponder(resp)
134 if err != nil {
135 err = autorest.NewErrorWithError(err, "siterecovery.TargetComputeSizesClient", "listByReplicationProtectedItemsNextResults", resp, "Failure responding to next results request")
136 }
137 return
138 }
139
140
141 func (client TargetComputeSizesClient) ListByReplicationProtectedItemsComplete(ctx context.Context, fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result TargetComputeSizeCollectionIterator, err error) {
142 if tracing.IsEnabled() {
143 ctx = tracing.StartSpan(ctx, fqdn+"/TargetComputeSizesClient.ListByReplicationProtectedItems")
144 defer func() {
145 sc := -1
146 if result.Response().Response.Response != nil {
147 sc = result.page.Response().Response.Response.StatusCode
148 }
149 tracing.EndSpan(ctx, sc, err)
150 }()
151 }
152 result.page, err = client.ListByReplicationProtectedItems(ctx, fabricName, protectionContainerName, replicatedProtectedItemName)
153 return
154 }
155
View as plain text