3
// Copyright (c) Microsoft and contributors. All rights reserved.
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
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.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
17
// Code generated by Microsoft (R) AutoRest Code Generator 0.12.0.0
18
// Changes may cause incorrect behavior and will be lost if the code is
22
"github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
27
// ServicesClient is the client that can be used to manage Azure Search
28
// services and API keys.
29
type ServicesClient struct {
33
// NewServicesClient creates an instance of the ServicesClient client.
34
func NewServicesClient(subscriptionID string) ServicesClient {
35
return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
38
// NewServicesClientWithBaseURI creates an instance of the ServicesClient
40
func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient {
41
return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
44
// CreateOrUpdate creates or updates a Search service in the given resource
45
// group. If the Search service already exists, all properties will be
46
// updated with the given values.
48
// resourceGroupName is the name of the resource group within the current
49
// subscription. serviceName is the name of the Search service to create or
50
// update. parameters is the properties to set or update on the Search
52
func (client ServicesClient) CreateOrUpdate(resourceGroupName string, serviceName string, parameters ServiceCreateOrUpdateParameters) (result ServiceResource, ae error) {
53
req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, parameters)
55
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure preparing request")
58
resp, err := client.CreateOrUpdateSender(req)
60
result.Response = autorest.Response{Response: resp}
61
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure sending request")
64
result, err = client.CreateOrUpdateResponder(resp)
66
ae = autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure responding to request")
72
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
73
func (client ServicesClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, parameters ServiceCreateOrUpdateParameters) (*http.Request, error) {
74
pathParameters := map[string]interface{}{
75
"resourceGroupName": url.QueryEscape(resourceGroupName),
76
"serviceName": url.QueryEscape(serviceName),
77
"subscriptionId": url.QueryEscape(client.SubscriptionID),
80
queryParameters := map[string]interface{}{
81
"api-version": APIVersion,
84
return autorest.Prepare(&http.Request{},
87
autorest.WithBaseURL(client.BaseURI),
88
autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}"),
89
autorest.WithJSON(parameters),
90
autorest.WithPathParameters(pathParameters),
91
autorest.WithQueryParameters(queryParameters))
94
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
95
// http.Response Body if it receives an error.
96
func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
97
return client.Send(req, http.StatusOK, http.StatusCreated)
100
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
101
// closes the http.Response Body.
102
func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) {
103
err = autorest.Respond(
105
client.ByInspecting(),
106
autorest.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
107
autorest.ByUnmarshallingJSON(&result),
108
autorest.ByClosing())
109
result.Response = autorest.Response{Response: resp}
113
// Delete deletes a Search service in the given resource group, along with its
114
// associated resources.
116
// resourceGroupName is the name of the resource group within the current
117
// subscription. serviceName is the name of the Search service to delete.
118
func (client ServicesClient) Delete(resourceGroupName string, serviceName string) (result autorest.Response, ae error) {
119
req, err := client.DeletePreparer(resourceGroupName, serviceName)
121
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure preparing request")
124
resp, err := client.DeleteSender(req)
126
result.Response = resp
127
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure sending request")
130
result, err = client.DeleteResponder(resp)
132
ae = autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure responding to request")
138
// DeletePreparer prepares the Delete request.
139
func (client ServicesClient) DeletePreparer(resourceGroupName string, serviceName string) (*http.Request, error) {
140
pathParameters := map[string]interface{}{
141
"resourceGroupName": url.QueryEscape(resourceGroupName),
142
"serviceName": url.QueryEscape(serviceName),
143
"subscriptionId": url.QueryEscape(client.SubscriptionID),
146
queryParameters := map[string]interface{}{
147
"api-version": APIVersion,
150
return autorest.Prepare(&http.Request{},
153
autorest.WithBaseURL(client.BaseURI),
154
autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}"),
155
autorest.WithPathParameters(pathParameters),
156
autorest.WithQueryParameters(queryParameters))
159
// DeleteSender sends the Delete request. The method will close the
160
// http.Response Body if it receives an error.
161
func (client ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) {
162
return client.Send(req, http.StatusOK, http.StatusNotFound, http.StatusNoContent)
165
// DeleteResponder handles the response to the Delete request. The method always
166
// closes the http.Response Body.
167
func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
168
err = autorest.Respond(
170
client.ByInspecting(),
171
autorest.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound, http.StatusNoContent),
172
autorest.ByClosing())
173
result.Response = resp
177
// List returns a list of all Search services in the given resource group.
179
// resourceGroupName is the name of the resource group within the current
181
func (client ServicesClient) List(resourceGroupName string) (result ServiceListResult, ae error) {
182
req, err := client.ListPreparer(resourceGroupName)
184
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure preparing request")
187
resp, err := client.ListSender(req)
189
result.Response = autorest.Response{Response: resp}
190
return result, autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure sending request")
193
result, err = client.ListResponder(resp)
195
ae = autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure responding to request")
201
// ListPreparer prepares the List request.
202
func (client ServicesClient) ListPreparer(resourceGroupName string) (*http.Request, error) {
203
pathParameters := map[string]interface{}{
204
"resourceGroupName": url.QueryEscape(resourceGroupName),
205
"subscriptionId": url.QueryEscape(client.SubscriptionID),
208
queryParameters := map[string]interface{}{
209
"api-version": APIVersion,
212
return autorest.Prepare(&http.Request{},
215
autorest.WithBaseURL(client.BaseURI),
216
autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices"),
217
autorest.WithPathParameters(pathParameters),
218
autorest.WithQueryParameters(queryParameters))
221
// ListSender sends the List request. The method will close the
222
// http.Response Body if it receives an error.
223
func (client ServicesClient) ListSender(req *http.Request) (*http.Response, error) {
224
return client.Send(req, http.StatusOK)
227
// ListResponder handles the response to the List request. The method always
228
// closes the http.Response Body.
229
func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) {
230
err = autorest.Respond(
232
client.ByInspecting(),
233
autorest.WithErrorUnlessStatusCode(http.StatusOK),
234
autorest.ByUnmarshallingJSON(&result),
235
autorest.ByClosing())
236
result.Response = autorest.Response{Response: resp}