~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/Azure/azure-sdk-for-go/arm/search/services.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package search
 
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 0.12.0.0
 
18
// Changes may cause incorrect behavior and will be lost if the code is
 
19
// regenerated.
 
20
 
 
21
import (
 
22
        "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
 
23
        "net/http"
 
24
        "net/url"
 
25
)
 
26
 
 
27
// ServicesClient is the client that can be used to manage Azure Search
 
28
// services and API keys.
 
29
type ServicesClient struct {
 
30
        ManagementClient
 
31
}
 
32
 
 
33
// NewServicesClient creates an instance of the ServicesClient client.
 
34
func NewServicesClient(subscriptionID string) ServicesClient {
 
35
        return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
 
36
}
 
37
 
 
38
// NewServicesClientWithBaseURI creates an instance of the ServicesClient
 
39
// client.
 
40
func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient {
 
41
        return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
 
42
}
 
43
 
 
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.
 
47
//
 
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
 
51
// service.
 
52
func (client ServicesClient) CreateOrUpdate(resourceGroupName string, serviceName string, parameters ServiceCreateOrUpdateParameters) (result ServiceResource, ae error) {
 
53
        req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, parameters)
 
54
        if err != nil {
 
55
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure preparing request")
 
56
        }
 
57
 
 
58
        resp, err := client.CreateOrUpdateSender(req)
 
59
        if err != nil {
 
60
                result.Response = autorest.Response{Response: resp}
 
61
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure sending request")
 
62
        }
 
63
 
 
64
        result, err = client.CreateOrUpdateResponder(resp)
 
65
        if err != nil {
 
66
                ae = autorest.NewErrorWithError(err, "search/ServicesClient", "CreateOrUpdate", "Failure responding to request")
 
67
        }
 
68
 
 
69
        return
 
70
}
 
71
 
 
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),
 
78
        }
 
79
 
 
80
        queryParameters := map[string]interface{}{
 
81
                "api-version": APIVersion,
 
82
        }
 
83
 
 
84
        return autorest.Prepare(&http.Request{},
 
85
                autorest.AsJSON(),
 
86
                autorest.AsPut(),
 
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))
 
92
}
 
93
 
 
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)
 
98
}
 
99
 
 
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(
 
104
                resp,
 
105
                client.ByInspecting(),
 
106
                autorest.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
 
107
                autorest.ByUnmarshallingJSON(&result),
 
108
                autorest.ByClosing())
 
109
        result.Response = autorest.Response{Response: resp}
 
110
        return
 
111
}
 
112
 
 
113
// Delete deletes a Search service in the given resource group, along with its
 
114
// associated resources.
 
115
//
 
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)
 
120
        if err != nil {
 
121
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure preparing request")
 
122
        }
 
123
 
 
124
        resp, err := client.DeleteSender(req)
 
125
        if err != nil {
 
126
                result.Response = resp
 
127
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure sending request")
 
128
        }
 
129
 
 
130
        result, err = client.DeleteResponder(resp)
 
131
        if err != nil {
 
132
                ae = autorest.NewErrorWithError(err, "search/ServicesClient", "Delete", "Failure responding to request")
 
133
        }
 
134
 
 
135
        return
 
136
}
 
137
 
 
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),
 
144
        }
 
145
 
 
146
        queryParameters := map[string]interface{}{
 
147
                "api-version": APIVersion,
 
148
        }
 
149
 
 
150
        return autorest.Prepare(&http.Request{},
 
151
                autorest.AsJSON(),
 
152
                autorest.AsDelete(),
 
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))
 
157
}
 
158
 
 
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)
 
163
}
 
164
 
 
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(
 
169
                resp,
 
170
                client.ByInspecting(),
 
171
                autorest.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound, http.StatusNoContent),
 
172
                autorest.ByClosing())
 
173
        result.Response = resp
 
174
        return
 
175
}
 
176
 
 
177
// List returns a list of all Search services in the given resource group.
 
178
//
 
179
// resourceGroupName is the name of the resource group within the current
 
180
// subscription.
 
181
func (client ServicesClient) List(resourceGroupName string) (result ServiceListResult, ae error) {
 
182
        req, err := client.ListPreparer(resourceGroupName)
 
183
        if err != nil {
 
184
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure preparing request")
 
185
        }
 
186
 
 
187
        resp, err := client.ListSender(req)
 
188
        if err != nil {
 
189
                result.Response = autorest.Response{Response: resp}
 
190
                return result, autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure sending request")
 
191
        }
 
192
 
 
193
        result, err = client.ListResponder(resp)
 
194
        if err != nil {
 
195
                ae = autorest.NewErrorWithError(err, "search/ServicesClient", "List", "Failure responding to request")
 
196
        }
 
197
 
 
198
        return
 
199
}
 
200
 
 
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),
 
206
        }
 
207
 
 
208
        queryParameters := map[string]interface{}{
 
209
                "api-version": APIVersion,
 
210
        }
 
211
 
 
212
        return autorest.Prepare(&http.Request{},
 
213
                autorest.AsJSON(),
 
214
                autorest.AsGet(),
 
215
                autorest.WithBaseURL(client.BaseURI),
 
216
                autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices"),
 
217
                autorest.WithPathParameters(pathParameters),
 
218
                autorest.WithQueryParameters(queryParameters))
 
219
}
 
220
 
 
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)
 
225
}
 
226
 
 
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(
 
231
                resp,
 
232
                client.ByInspecting(),
 
233
                autorest.WithErrorUnlessStatusCode(http.StatusOK),
 
234
                autorest.ByUnmarshallingJSON(&result),
 
235
                autorest.ByClosing())
 
236
        result.Response = autorest.Response{Response: resp}
 
237
        return
 
238
}