1package datamigration
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"net/http"
25)
26
27// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
28// OperationsClient is the data Migration Client
29type OperationsClient struct {
30	BaseClient
31}
32
33// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
34// NewOperationsClient creates an instance of the OperationsClient client.
35func NewOperationsClient(subscriptionID string) OperationsClient {
36	return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
40// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client.
41func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
42	return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
46// List lists all available actions exposed by the Data Migration Service resource provider.
47func (client OperationsClient) List(ctx context.Context) (result ServiceOperationListPage, err error) {
48	result.fn = client.listNextResults
49	req, err := client.ListPreparer(ctx)
50	if err != nil {
51		err = autorest.NewErrorWithError(err, "datamigration.OperationsClient", "List", nil, "Failure preparing request")
52		return
53	}
54
55	resp, err := client.ListSender(req)
56	if err != nil {
57		result.sol.Response = autorest.Response{Response: resp}
58		err = autorest.NewErrorWithError(err, "datamigration.OperationsClient", "List", resp, "Failure sending request")
59		return
60	}
61
62	result.sol, err = client.ListResponder(resp)
63	if err != nil {
64		err = autorest.NewErrorWithError(err, "datamigration.OperationsClient", "List", resp, "Failure responding to request")
65	}
66
67	return
68}
69
70// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
71// ListPreparer prepares the List request.
72func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
73	const APIVersion = "2017-11-15-preview"
74	queryParameters := map[string]interface{}{
75		"api-version": APIVersion,
76	}
77
78	preparer := autorest.CreatePreparer(
79		autorest.AsGet(),
80		autorest.WithBaseURL(client.BaseURI),
81		autorest.WithPath("/providers/Microsoft.DataMigration/operations"),
82		autorest.WithQueryParameters(queryParameters))
83	return preparer.Prepare((&http.Request{}).WithContext(ctx))
84}
85
86// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
87// ListSender sends the List request. The method will close the
88// http.Response Body if it receives an error.
89func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
90	return autorest.SendWithSender(client, req,
91		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
92}
93
94// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
95// ListResponder handles the response to the List request. The method always
96// closes the http.Response Body.
97func (client OperationsClient) ListResponder(resp *http.Response) (result ServiceOperationList, err error) {
98	err = autorest.Respond(
99		resp,
100		client.ByInspecting(),
101		azure.WithErrorUnlessStatusCode(http.StatusOK),
102		autorest.ByUnmarshallingJSON(&result),
103		autorest.ByClosing())
104	result.Response = autorest.Response{Response: resp}
105	return
106}
107
108// listNextResults retrieves the next set of results, if any.
109func (client OperationsClient) listNextResults(lastResults ServiceOperationList) (result ServiceOperationList, err error) {
110	req, err := lastResults.serviceOperationListPreparer()
111	if err != nil {
112		return result, autorest.NewErrorWithError(err, "datamigration.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
113	}
114	if req == nil {
115		return
116	}
117	resp, err := client.ListSender(req)
118	if err != nil {
119		result.Response = autorest.Response{Response: resp}
120		return result, autorest.NewErrorWithError(err, "datamigration.OperationsClient", "listNextResults", resp, "Failure sending next results request")
121	}
122	result, err = client.ListResponder(resp)
123	if err != nil {
124		err = autorest.NewErrorWithError(err, "datamigration.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
125	}
126	return
127}
128
129// Deprecated: Please use package github.com/Azure/azure-sdk-for-go/services/preview/datamigration/mgmt/2017-11-15-preview/datamigration instead.
130// ListComplete enumerates all values, automatically crossing page boundaries as required.
131func (client OperationsClient) ListComplete(ctx context.Context) (result ServiceOperationListIterator, err error) {
132	result.page, err = client.List(ctx)
133	return
134}
135