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
19 type ReplicationLogicalNetworksClient struct {
20 BaseClient
21 }
22
23
24 func NewReplicationLogicalNetworksClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationLogicalNetworksClient {
25 return NewReplicationLogicalNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
26 }
27
28
29
30
31 func NewReplicationLogicalNetworksClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationLogicalNetworksClient {
32 return ReplicationLogicalNetworksClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
33 }
34
35
36
37
38
39 func (client ReplicationLogicalNetworksClient) Get(ctx context.Context, fabricName string, logicalNetworkName string) (result LogicalNetwork, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLogicalNetworksClient.Get")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 req, err := client.GetPreparer(ctx, fabricName, logicalNetworkName)
51 if err != nil {
52 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "Get", nil, "Failure preparing request")
53 return
54 }
55
56 resp, err := client.GetSender(req)
57 if err != nil {
58 result.Response = autorest.Response{Response: resp}
59 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "Get", resp, "Failure sending request")
60 return
61 }
62
63 result, err = client.GetResponder(resp)
64 if err != nil {
65 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "Get", resp, "Failure responding to request")
66 return
67 }
68
69 return
70 }
71
72
73 func (client ReplicationLogicalNetworksClient) GetPreparer(ctx context.Context, fabricName string, logicalNetworkName string) (*http.Request, error) {
74 pathParameters := map[string]interface{}{
75 "fabricName": autorest.Encode("path", fabricName),
76 "logicalNetworkName": autorest.Encode("path", logicalNetworkName),
77 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
78 "resourceName": autorest.Encode("path", client.ResourceName),
79 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
80 }
81
82 const APIVersion = "2016-08-10"
83 queryParameters := map[string]interface{}{
84 "api-version": APIVersion,
85 }
86
87 preparer := autorest.CreatePreparer(
88 autorest.AsGet(),
89 autorest.WithBaseURL(client.BaseURI),
90 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationLogicalNetworks/{logicalNetworkName}", pathParameters),
91 autorest.WithQueryParameters(queryParameters))
92 return preparer.Prepare((&http.Request{}).WithContext(ctx))
93 }
94
95
96
97 func (client ReplicationLogicalNetworksClient) GetSender(req *http.Request) (*http.Response, error) {
98 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
99 }
100
101
102
103 func (client ReplicationLogicalNetworksClient) GetResponder(resp *http.Response) (result LogicalNetwork, err error) {
104 err = autorest.Respond(
105 resp,
106 azure.WithErrorUnlessStatusCode(http.StatusOK),
107 autorest.ByUnmarshallingJSON(&result),
108 autorest.ByClosing())
109 result.Response = autorest.Response{Response: resp}
110 return
111 }
112
113
114
115
116 func (client ReplicationLogicalNetworksClient) ListByReplicationFabrics(ctx context.Context, fabricName string) (result LogicalNetworkCollectionPage, err error) {
117 if tracing.IsEnabled() {
118 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLogicalNetworksClient.ListByReplicationFabrics")
119 defer func() {
120 sc := -1
121 if result.lnc.Response.Response != nil {
122 sc = result.lnc.Response.Response.StatusCode
123 }
124 tracing.EndSpan(ctx, sc, err)
125 }()
126 }
127 result.fn = client.listByReplicationFabricsNextResults
128 req, err := client.ListByReplicationFabricsPreparer(ctx, fabricName)
129 if err != nil {
130 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", nil, "Failure preparing request")
131 return
132 }
133
134 resp, err := client.ListByReplicationFabricsSender(req)
135 if err != nil {
136 result.lnc.Response = autorest.Response{Response: resp}
137 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure sending request")
138 return
139 }
140
141 result.lnc, err = client.ListByReplicationFabricsResponder(resp)
142 if err != nil {
143 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure responding to request")
144 return
145 }
146 if result.lnc.hasNextLink() && result.lnc.IsEmpty() {
147 err = result.NextWithContext(ctx)
148 return
149 }
150
151 return
152 }
153
154
155 func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
156 pathParameters := map[string]interface{}{
157 "fabricName": autorest.Encode("path", fabricName),
158 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
159 "resourceName": autorest.Encode("path", client.ResourceName),
160 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
161 }
162
163 const APIVersion = "2016-08-10"
164 queryParameters := map[string]interface{}{
165 "api-version": APIVersion,
166 }
167
168 preparer := autorest.CreatePreparer(
169 autorest.AsGet(),
170 autorest.WithBaseURL(client.BaseURI),
171 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationLogicalNetworks", pathParameters),
172 autorest.WithQueryParameters(queryParameters))
173 return preparer.Prepare((&http.Request{}).WithContext(ctx))
174 }
175
176
177
178 func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) {
179 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
180 }
181
182
183
184 func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsResponder(resp *http.Response) (result LogicalNetworkCollection, err error) {
185 err = autorest.Respond(
186 resp,
187 azure.WithErrorUnlessStatusCode(http.StatusOK),
188 autorest.ByUnmarshallingJSON(&result),
189 autorest.ByClosing())
190 result.Response = autorest.Response{Response: resp}
191 return
192 }
193
194
195 func (client ReplicationLogicalNetworksClient) listByReplicationFabricsNextResults(ctx context.Context, lastResults LogicalNetworkCollection) (result LogicalNetworkCollection, err error) {
196 req, err := lastResults.logicalNetworkCollectionPreparer(ctx)
197 if err != nil {
198 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "listByReplicationFabricsNextResults", nil, "Failure preparing next results request")
199 }
200 if req == nil {
201 return
202 }
203 resp, err := client.ListByReplicationFabricsSender(req)
204 if err != nil {
205 result.Response = autorest.Response{Response: resp}
206 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "listByReplicationFabricsNextResults", resp, "Failure sending next results request")
207 }
208 result, err = client.ListByReplicationFabricsResponder(resp)
209 if err != nil {
210 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationLogicalNetworksClient", "listByReplicationFabricsNextResults", resp, "Failure responding to next results request")
211 }
212 return
213 }
214
215
216 func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, fabricName string) (result LogicalNetworkCollectionIterator, err error) {
217 if tracing.IsEnabled() {
218 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLogicalNetworksClient.ListByReplicationFabrics")
219 defer func() {
220 sc := -1
221 if result.Response().Response.Response != nil {
222 sc = result.page.Response().Response.Response.StatusCode
223 }
224 tracing.EndSpan(ctx, sc, err)
225 }()
226 }
227 result.page, err = client.ListByReplicationFabrics(ctx, fabricName)
228 return
229 }
230
View as plain text