forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
427 lines (391 loc) · 18.5 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
package search
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"net/http"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search"
// AdminKeyResult response containing the primary and secondary admin API keys for a given Azure Cognitive
// Search service.
type AdminKeyResult struct {
autorest.Response `json:"-"`
// PrimaryKey - READ-ONLY; The primary admin API key of the Search service.
PrimaryKey *string `json:"primaryKey,omitempty"`
// SecondaryKey - READ-ONLY; The secondary admin API key of the Search service.
SecondaryKey *string `json:"secondaryKey,omitempty"`
}
// MarshalJSON is the custom marshaler for AdminKeyResult.
func (akr AdminKeyResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// CheckNameAvailabilityInput input of check name availability API.
type CheckNameAvailabilityInput struct {
// Name - The Search service name to validate. Search service names must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in length.
Name *string `json:"name,omitempty"`
// Type - The type of the resource whose name is to be validated. This value must always be 'searchServices'.
Type *string `json:"type,omitempty"`
}
// CheckNameAvailabilityOutput output of check name availability API.
type CheckNameAvailabilityOutput struct {
autorest.Response `json:"-"`
// IsNameAvailable - READ-ONLY; A value indicating whether the name is available.
IsNameAvailable *bool `json:"nameAvailable,omitempty"`
// Reason - READ-ONLY; The reason why the name is not available. 'Invalid' indicates the name provided does not match the naming requirements (incorrect length, unsupported characters, etc.). 'AlreadyExists' indicates that the name is already in use and is therefore unavailable. Possible values include: 'Invalid', 'AlreadyExists'
Reason UnavailableNameReason `json:"reason,omitempty"`
// Message - READ-ONLY; A message that explains why the name is invalid and provides resource naming requirements. Available only if 'Invalid' is returned in the 'reason' property.
Message *string `json:"message,omitempty"`
}
// MarshalJSON is the custom marshaler for CheckNameAvailabilityOutput.
func (cnao CheckNameAvailabilityOutput) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// CloudError contains information about an API error.
type CloudError struct {
// Error - Describes a particular API error with an error code and a message.
Error *CloudErrorBody `json:"error,omitempty"`
}
// CloudErrorBody describes a particular API error with an error code and a message.
type CloudErrorBody struct {
// Code - An error code that describes the error condition more precisely than an HTTP status code. Can be used to programmatically handle specific error cases.
Code *string `json:"code,omitempty"`
// Message - A message that describes the error in detail and provides debugging information.
Message *string `json:"message,omitempty"`
// Target - The target of the particular error (for example, the name of the property in error).
Target *string `json:"target,omitempty"`
// Details - Contains nested errors that are related to this error.
Details *[]CloudErrorBody `json:"details,omitempty"`
}
// Identity identity for the resource.
type Identity struct {
// PrincipalID - READ-ONLY; The principal ID of resource identity.
PrincipalID *string `json:"principalId,omitempty"`
// TenantID - READ-ONLY; The tenant ID of resource.
TenantID *string `json:"tenantId,omitempty"`
// Type - The identity type. Possible values include: 'None', 'SystemAssigned'
Type IdentityType `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for Identity.
func (i Identity) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if i.Type != "" {
objectMap["type"] = i.Type
}
return json.Marshal(objectMap)
}
// ListQueryKeysResult response containing the query API keys for a given Azure Cognitive Search service.
type ListQueryKeysResult struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The query keys for the Azure Cognitive Search service.
Value *[]QueryKey `json:"value,omitempty"`
}
// MarshalJSON is the custom marshaler for ListQueryKeysResult.
func (lqkr ListQueryKeysResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// Operation describes a REST API operation.
type Operation struct {
// Name - READ-ONLY; The name of the operation. This name is of the form {provider}/{resource}/{operation}.
Name *string `json:"name,omitempty"`
// Display - READ-ONLY; The object that describes the operation.
Display *OperationDisplay `json:"display,omitempty"`
}
// MarshalJSON is the custom marshaler for Operation.
func (o Operation) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// OperationDisplay the object that describes the operation.
type OperationDisplay struct {
// Provider - READ-ONLY; The friendly name of the resource provider.
Provider *string `json:"provider,omitempty"`
// Operation - READ-ONLY; The operation type: read, write, delete, listKeys/action, etc.
Operation *string `json:"operation,omitempty"`
// Resource - READ-ONLY; The resource type on which the operation is performed.
Resource *string `json:"resource,omitempty"`
// Description - READ-ONLY; The friendly name of the operation.
Description *string `json:"description,omitempty"`
}
// MarshalJSON is the custom marshaler for OperationDisplay.
func (o OperationDisplay) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// OperationListResult the result of the request to list REST API operations. It contains a list of
// operations and a URL to get the next set of results.
type OperationListResult struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The list of operations supported by the resource provider.
Value *[]Operation `json:"value,omitempty"`
// NextLink - READ-ONLY; The URL to get the next set of operation list results, if any.
NextLink *string `json:"nextLink,omitempty"`
}
// MarshalJSON is the custom marshaler for OperationListResult.
func (olr OperationListResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// QueryKey describes an API key for a given Azure Cognitive Search service that has permissions for query
// operations only.
type QueryKey struct {
autorest.Response `json:"-"`
// Name - READ-ONLY; The name of the query API key; may be empty.
Name *string `json:"name,omitempty"`
// Key - READ-ONLY; The value of the query API key.
Key *string `json:"key,omitempty"`
}
// MarshalJSON is the custom marshaler for QueryKey.
func (qk QueryKey) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// Resource base type for all Azure resources.
type Resource struct {
// ID - READ-ONLY; The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; The name of the resource.
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; The resource type.
Type *string `json:"type,omitempty"`
// Location - The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). This property is required when creating a new resource.
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the resource in the Azure portal.
Tags map[string]*string `json:"tags"`
// Identity - The identity of the resource.
Identity *Identity `json:"identity,omitempty"`
}
// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if r.Location != nil {
objectMap["location"] = r.Location
}
if r.Tags != nil {
objectMap["tags"] = r.Tags
}
if r.Identity != nil {
objectMap["identity"] = r.Identity
}
return json.Marshal(objectMap)
}
// Service describes an Azure Cognitive Search service and its current state.
type Service struct {
autorest.Response `json:"-"`
// ServiceProperties - Properties of the Search service.
*ServiceProperties `json:"properties,omitempty"`
// Sku - The SKU of the Search Service, which determines price tier and capacity limits. This property is required when creating a new Search Service.
Sku *Sku `json:"sku,omitempty"`
// ID - READ-ONLY; The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; The name of the resource.
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; The resource type.
Type *string `json:"type,omitempty"`
// Location - The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). This property is required when creating a new resource.
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the resource in the Azure portal.
Tags map[string]*string `json:"tags"`
// Identity - The identity of the resource.
Identity *Identity `json:"identity,omitempty"`
}
// MarshalJSON is the custom marshaler for Service.
func (s Service) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if s.ServiceProperties != nil {
objectMap["properties"] = s.ServiceProperties
}
if s.Sku != nil {
objectMap["sku"] = s.Sku
}
if s.Location != nil {
objectMap["location"] = s.Location
}
if s.Tags != nil {
objectMap["tags"] = s.Tags
}
if s.Identity != nil {
objectMap["identity"] = s.Identity
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for Service struct.
func (s *Service) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var serviceProperties ServiceProperties
err = json.Unmarshal(*v, &serviceProperties)
if err != nil {
return err
}
s.ServiceProperties = &serviceProperties
}
case "sku":
if v != nil {
var sku Sku
err = json.Unmarshal(*v, &sku)
if err != nil {
return err
}
s.Sku = &sku
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
s.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
s.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
s.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
s.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
s.Tags = tags
}
case "identity":
if v != nil {
var identity Identity
err = json.Unmarshal(*v, &identity)
if err != nil {
return err
}
s.Identity = &identity
}
}
}
return nil
}
// ServiceListResult response containing a list of Azure Cognitive Search services.
type ServiceListResult struct {
autorest.Response `json:"-"`
// Value - READ-ONLY; The list of Search services.
Value *[]Service `json:"value,omitempty"`
}
// MarshalJSON is the custom marshaler for ServiceListResult.
func (slr ServiceListResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// ServiceProperties properties of the Search service.
type ServiceProperties struct {
// ReplicaCount - The number of replicas in the Search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU.
ReplicaCount *int32 `json:"replicaCount,omitempty"`
// PartitionCount - The number of partitions in the Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3.
PartitionCount *int32 `json:"partitionCount,omitempty"`
// HostingMode - Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: 'Default', 'HighDensity'
HostingMode HostingMode `json:"hostingMode,omitempty"`
// Status - READ-ONLY; The status of the Search service. Possible values include: 'running': The Search service is running and no provisioning operations are underway. 'provisioning': The Search service is being provisioned or scaled up or down. 'deleting': The Search service is being deleted. 'degraded': The Search service is degraded. This can occur when the underlying search units are not healthy. The Search service is most likely operational, but performance might be slow and some requests might be dropped. 'disabled': The Search service is disabled. In this state, the service will reject all API requests. 'error': The Search service is in an error state. If your service is in the degraded, disabled, or error states, it means the Azure Cognitive Search team is actively investigating the underlying issue. Dedicated services in these states are still chargeable based on the number of search units provisioned. Possible values include: 'ServiceStatusRunning', 'ServiceStatusProvisioning', 'ServiceStatusDeleting', 'ServiceStatusDegraded', 'ServiceStatusDisabled', 'ServiceStatusError'
Status ServiceStatus `json:"status,omitempty"`
// StatusDetails - READ-ONLY; The details of the Search service status.
StatusDetails *string `json:"statusDetails,omitempty"`
// ProvisioningState - READ-ONLY; The state of the last provisioning operation performed on the Search service. Provisioning is an intermediate state that occurs while service capacity is being established. After capacity is set up, provisioningState changes to either 'succeeded' or 'failed'. Client applications can poll provisioning status (the recommended polling interval is from 30 seconds to one minute) by using the Get Search Service operation to see when an operation is completed. If you are using the free service, this value tends to come back as 'succeeded' directly in the call to Create Search service. This is because the free service uses capacity that is already set up. Possible values include: 'Succeeded', 'Provisioning', 'Failed'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
}
// MarshalJSON is the custom marshaler for ServiceProperties.
func (sp ServiceProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if sp.ReplicaCount != nil {
objectMap["replicaCount"] = sp.ReplicaCount
}
if sp.PartitionCount != nil {
objectMap["partitionCount"] = sp.PartitionCount
}
if sp.HostingMode != "" {
objectMap["hostingMode"] = sp.HostingMode
}
return json.Marshal(objectMap)
}
// ServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
// operation.
type ServicesCreateOrUpdateFuture struct {
azure.FutureAPI
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
Result func(ServicesClient) (Service, error)
}
// UnmarshalJSON is the custom unmarshaller for CreateFuture.
func (future *ServicesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error {
var azFuture azure.Future
if err := json.Unmarshal(body, &azFuture); err != nil {
return err
}
future.FutureAPI = &azFuture
future.Result = future.result
return nil
}
// result is the default implementation for ServicesCreateOrUpdateFuture.Result.
func (future *ServicesCreateOrUpdateFuture) result(client ServicesClient) (s Service, err error) {
var done bool
done, err = future.DoneWithContext(context.Background(), client)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
return
}
if !done {
s.Response.Response = future.Response()
err = azure.NewAsyncOpIncompleteError("search.ServicesCreateOrUpdateFuture")
return
}
sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
s, err = client.CreateOrUpdateResponder(s.Response.Response)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request")
}
}
return
}
// Sku defines the SKU of an Azure Cognitive Search Service, which determines price tier and capacity
// limits.
type Sku struct {
// Name - The SKU of the Search service. Valid values include: 'free': Shared service. 'basic': Dedicated service with up to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 replicas. 'standard2': Similar to standard, but with more capacity per search unit. 'standard3': The largest Standard offering with up to 12 partitions and 12 replicas (or up to 3 partitions with more indexes if you also set the hostingMode property to 'highDensity'). 'storage_optimized_l1': Supports 1TB per partition, up to 12 partitions. 'storage_optimized_l2': Supports 2TB per partition, up to 12 partitions.'. Possible values include: 'Free', 'Basic', 'Standard', 'Standard2', 'Standard3', 'StorageOptimizedL1', 'StorageOptimizedL2'
Name SkuName `json:"name,omitempty"`
}