1package 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.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2020-03-13/search"
32
33// AdminKeyResult response containing the primary and secondary admin API keys for a given Azure Cognitive
34// Search service.
35type AdminKeyResult struct {
36	autorest.Response `json:"-"`
37	// PrimaryKey - READ-ONLY; The primary admin API key of the Search service.
38	PrimaryKey *string `json:"primaryKey,omitempty"`
39	// SecondaryKey - READ-ONLY; The secondary admin API key of the Search service.
40	SecondaryKey *string `json:"secondaryKey,omitempty"`
41}
42
43// CheckNameAvailabilityInput input of check name availability API.
44type CheckNameAvailabilityInput struct {
45	// 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.
46	Name *string `json:"name,omitempty"`
47	// Type - The type of the resource whose name is to be validated. This value must always be 'searchServices'.
48	Type *string `json:"type,omitempty"`
49}
50
51// CheckNameAvailabilityOutput output of check name availability API.
52type CheckNameAvailabilityOutput struct {
53	autorest.Response `json:"-"`
54	// IsNameAvailable - READ-ONLY; A value indicating whether the name is available.
55	IsNameAvailable *bool `json:"nameAvailable,omitempty"`
56	// 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'
57	Reason UnavailableNameReason `json:"reason,omitempty"`
58	// 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.
59	Message *string `json:"message,omitempty"`
60}
61
62// CloudError contains information about an API error.
63type CloudError struct {
64	// Error - Describes a particular API error with an error code and a message.
65	Error *CloudErrorBody `json:"error,omitempty"`
66}
67
68// CloudErrorBody describes a particular API error with an error code and a message.
69type CloudErrorBody struct {
70	// 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.
71	Code *string `json:"code,omitempty"`
72	// Message - A message that describes the error in detail and provides debugging information.
73	Message *string `json:"message,omitempty"`
74	// Target - The target of the particular error (for example, the name of the property in error).
75	Target *string `json:"target,omitempty"`
76	// Details - Contains nested errors that are related to this error.
77	Details *[]CloudErrorBody `json:"details,omitempty"`
78}
79
80// Identity identity for the resource.
81type Identity struct {
82	// PrincipalID - READ-ONLY; The principal ID of resource identity.
83	PrincipalID *string `json:"principalId,omitempty"`
84	// TenantID - READ-ONLY; The tenant ID of resource.
85	TenantID *string `json:"tenantId,omitempty"`
86	// Type - The identity type. Possible values include: 'None', 'SystemAssigned'
87	Type IdentityType `json:"type,omitempty"`
88}
89
90// MarshalJSON is the custom marshaler for Identity.
91func (i Identity) MarshalJSON() ([]byte, error) {
92	objectMap := make(map[string]interface{})
93	if i.Type != "" {
94		objectMap["type"] = i.Type
95	}
96	return json.Marshal(objectMap)
97}
98
99// IPRule the IP restriction rule of the Azure Cognitive Search service.
100type IPRule struct {
101	// Value - Value corresponding to a single IPv4 address (eg., 123.1.2.3) or an IP range in CIDR format (eg., 123.1.2.3/24) to be allowed.
102	Value *string `json:"value,omitempty"`
103}
104
105// ListQueryKeysResult response containing the query API keys for a given Azure Cognitive Search service.
106type ListQueryKeysResult struct {
107	autorest.Response `json:"-"`
108	// Value - READ-ONLY; The query keys for the Azure Cognitive Search service.
109	Value *[]QueryKey `json:"value,omitempty"`
110	// NextLink - READ-ONLY; Request URL that can be used to query next page of query keys. Returned when the total number of requested query keys exceed maximum page size.
111	NextLink *string `json:"nextLink,omitempty"`
112}
113
114// ListQueryKeysResultIterator provides access to a complete listing of QueryKey values.
115type ListQueryKeysResultIterator struct {
116	i    int
117	page ListQueryKeysResultPage
118}
119
120// NextWithContext advances to the next value.  If there was an error making
121// the request the iterator does not advance and the error is returned.
122func (iter *ListQueryKeysResultIterator) NextWithContext(ctx context.Context) (err error) {
123	if tracing.IsEnabled() {
124		ctx = tracing.StartSpan(ctx, fqdn+"/ListQueryKeysResultIterator.NextWithContext")
125		defer func() {
126			sc := -1
127			if iter.Response().Response.Response != nil {
128				sc = iter.Response().Response.Response.StatusCode
129			}
130			tracing.EndSpan(ctx, sc, err)
131		}()
132	}
133	iter.i++
134	if iter.i < len(iter.page.Values()) {
135		return nil
136	}
137	err = iter.page.NextWithContext(ctx)
138	if err != nil {
139		iter.i--
140		return err
141	}
142	iter.i = 0
143	return nil
144}
145
146// Next advances to the next value.  If there was an error making
147// the request the iterator does not advance and the error is returned.
148// Deprecated: Use NextWithContext() instead.
149func (iter *ListQueryKeysResultIterator) Next() error {
150	return iter.NextWithContext(context.Background())
151}
152
153// NotDone returns true if the enumeration should be started or is not yet complete.
154func (iter ListQueryKeysResultIterator) NotDone() bool {
155	return iter.page.NotDone() && iter.i < len(iter.page.Values())
156}
157
158// Response returns the raw server response from the last page request.
159func (iter ListQueryKeysResultIterator) Response() ListQueryKeysResult {
160	return iter.page.Response()
161}
162
163// Value returns the current value or a zero-initialized value if the
164// iterator has advanced beyond the end of the collection.
165func (iter ListQueryKeysResultIterator) Value() QueryKey {
166	if !iter.page.NotDone() {
167		return QueryKey{}
168	}
169	return iter.page.Values()[iter.i]
170}
171
172// Creates a new instance of the ListQueryKeysResultIterator type.
173func NewListQueryKeysResultIterator(page ListQueryKeysResultPage) ListQueryKeysResultIterator {
174	return ListQueryKeysResultIterator{page: page}
175}
176
177// IsEmpty returns true if the ListResult contains no values.
178func (lqkr ListQueryKeysResult) IsEmpty() bool {
179	return lqkr.Value == nil || len(*lqkr.Value) == 0
180}
181
182// hasNextLink returns true if the NextLink is not empty.
183func (lqkr ListQueryKeysResult) hasNextLink() bool {
184	return lqkr.NextLink != nil && len(*lqkr.NextLink) != 0
185}
186
187// listQueryKeysResultPreparer prepares a request to retrieve the next set of results.
188// It returns nil if no more results exist.
189func (lqkr ListQueryKeysResult) listQueryKeysResultPreparer(ctx context.Context) (*http.Request, error) {
190	if !lqkr.hasNextLink() {
191		return nil, nil
192	}
193	return autorest.Prepare((&http.Request{}).WithContext(ctx),
194		autorest.AsJSON(),
195		autorest.AsGet(),
196		autorest.WithBaseURL(to.String(lqkr.NextLink)))
197}
198
199// ListQueryKeysResultPage contains a page of QueryKey values.
200type ListQueryKeysResultPage struct {
201	fn   func(context.Context, ListQueryKeysResult) (ListQueryKeysResult, error)
202	lqkr ListQueryKeysResult
203}
204
205// NextWithContext advances to the next page of values.  If there was an error making
206// the request the page does not advance and the error is returned.
207func (page *ListQueryKeysResultPage) NextWithContext(ctx context.Context) (err error) {
208	if tracing.IsEnabled() {
209		ctx = tracing.StartSpan(ctx, fqdn+"/ListQueryKeysResultPage.NextWithContext")
210		defer func() {
211			sc := -1
212			if page.Response().Response.Response != nil {
213				sc = page.Response().Response.Response.StatusCode
214			}
215			tracing.EndSpan(ctx, sc, err)
216		}()
217	}
218	for {
219		next, err := page.fn(ctx, page.lqkr)
220		if err != nil {
221			return err
222		}
223		page.lqkr = next
224		if !next.hasNextLink() || !next.IsEmpty() {
225			break
226		}
227	}
228	return nil
229}
230
231// Next advances to the next page of values.  If there was an error making
232// the request the page does not advance and the error is returned.
233// Deprecated: Use NextWithContext() instead.
234func (page *ListQueryKeysResultPage) Next() error {
235	return page.NextWithContext(context.Background())
236}
237
238// NotDone returns true if the page enumeration should be started or is not yet complete.
239func (page ListQueryKeysResultPage) NotDone() bool {
240	return !page.lqkr.IsEmpty()
241}
242
243// Response returns the raw server response from the last page request.
244func (page ListQueryKeysResultPage) Response() ListQueryKeysResult {
245	return page.lqkr
246}
247
248// Values returns the slice of values for the current page or nil if there are no values.
249func (page ListQueryKeysResultPage) Values() []QueryKey {
250	if page.lqkr.IsEmpty() {
251		return nil
252	}
253	return *page.lqkr.Value
254}
255
256// Creates a new instance of the ListQueryKeysResultPage type.
257func NewListQueryKeysResultPage(cur ListQueryKeysResult, getNextPage func(context.Context, ListQueryKeysResult) (ListQueryKeysResult, error)) ListQueryKeysResultPage {
258	return ListQueryKeysResultPage{
259		fn:   getNextPage,
260		lqkr: cur,
261	}
262}
263
264// NetworkRuleSet network specific rules that determine how the Azure Cognitive Search service may be
265// reached.
266type NetworkRuleSet struct {
267	// IPRules - A list of IP restriction rules that defines the inbound network(s) with allowing access to the search service endpoint. At the meantime, all other public IP networks are blocked by the firewall. These restriction rules are applied only when the 'publicNetworkAccess' of the search service is 'enabled'; otherwise, traffic over public interface is not allowed even with any public IP rules, and private endpoint connections would be the exclusive access method.
268	IPRules *[]IPRule `json:"ipRules,omitempty"`
269}
270
271// Operation describes a REST API operation.
272type Operation struct {
273	// Name - READ-ONLY; The name of the operation. This name is of the form {provider}/{resource}/{operation}.
274	Name *string `json:"name,omitempty"`
275	// Display - READ-ONLY; The object that describes the operation.
276	Display *OperationDisplay `json:"display,omitempty"`
277}
278
279// OperationDisplay the object that describes the operation.
280type OperationDisplay struct {
281	// Provider - READ-ONLY; The friendly name of the resource provider.
282	Provider *string `json:"provider,omitempty"`
283	// Operation - READ-ONLY; The operation type: read, write, delete, listKeys/action, etc.
284	Operation *string `json:"operation,omitempty"`
285	// Resource - READ-ONLY; The resource type on which the operation is performed.
286	Resource *string `json:"resource,omitempty"`
287	// Description - READ-ONLY; The friendly name of the operation.
288	Description *string `json:"description,omitempty"`
289}
290
291// OperationListResult the result of the request to list REST API operations. It contains a list of
292// operations and a URL  to get the next set of results.
293type OperationListResult struct {
294	autorest.Response `json:"-"`
295	// Value - READ-ONLY; The list of operations supported by the resource provider.
296	Value *[]Operation `json:"value,omitempty"`
297	// NextLink - READ-ONLY; The URL to get the next set of operation list results, if any.
298	NextLink *string `json:"nextLink,omitempty"`
299}
300
301// PrivateEndpointConnection describes an existing Private Endpoint connection to the Azure Cognitive
302// Search service.
303type PrivateEndpointConnection struct {
304	autorest.Response `json:"-"`
305	// ID - READ-ONLY; The ID of the private endpoint connection. This can be used with the Azure Resource Manager to link resources together.
306	ID *string `json:"id,omitempty"`
307	// Name - READ-ONLY; The name of the private endpoint connection.
308	Name *string `json:"name,omitempty"`
309	// Type - READ-ONLY; The resource type.
310	Type *string `json:"type,omitempty"`
311	// Properties - Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service.
312	Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"`
313}
314
315// MarshalJSON is the custom marshaler for PrivateEndpointConnection.
316func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) {
317	objectMap := make(map[string]interface{})
318	if pec.Properties != nil {
319		objectMap["properties"] = pec.Properties
320	}
321	return json.Marshal(objectMap)
322}
323
324// PrivateEndpointConnectionListResult response containing a list of Private Endpoint connections.
325type PrivateEndpointConnectionListResult struct {
326	autorest.Response `json:"-"`
327	// Value - READ-ONLY; The list of Private Endpoint connections.
328	Value *[]PrivateEndpointConnection `json:"value,omitempty"`
329	// NextLink - READ-ONLY; Request URL that can be used to query next page of private endpoint connections. Returned when the total number of requested private endpoint connections exceed maximum page size.
330	NextLink *string `json:"nextLink,omitempty"`
331}
332
333// PrivateEndpointConnectionListResultIterator provides access to a complete listing of
334// PrivateEndpointConnection values.
335type PrivateEndpointConnectionListResultIterator struct {
336	i    int
337	page PrivateEndpointConnectionListResultPage
338}
339
340// NextWithContext advances to the next value.  If there was an error making
341// the request the iterator does not advance and the error is returned.
342func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) {
343	if tracing.IsEnabled() {
344		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext")
345		defer func() {
346			sc := -1
347			if iter.Response().Response.Response != nil {
348				sc = iter.Response().Response.Response.StatusCode
349			}
350			tracing.EndSpan(ctx, sc, err)
351		}()
352	}
353	iter.i++
354	if iter.i < len(iter.page.Values()) {
355		return nil
356	}
357	err = iter.page.NextWithContext(ctx)
358	if err != nil {
359		iter.i--
360		return err
361	}
362	iter.i = 0
363	return nil
364}
365
366// Next advances to the next value.  If there was an error making
367// the request the iterator does not advance and the error is returned.
368// Deprecated: Use NextWithContext() instead.
369func (iter *PrivateEndpointConnectionListResultIterator) Next() error {
370	return iter.NextWithContext(context.Background())
371}
372
373// NotDone returns true if the enumeration should be started or is not yet complete.
374func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool {
375	return iter.page.NotDone() && iter.i < len(iter.page.Values())
376}
377
378// Response returns the raw server response from the last page request.
379func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult {
380	return iter.page.Response()
381}
382
383// Value returns the current value or a zero-initialized value if the
384// iterator has advanced beyond the end of the collection.
385func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection {
386	if !iter.page.NotDone() {
387		return PrivateEndpointConnection{}
388	}
389	return iter.page.Values()[iter.i]
390}
391
392// Creates a new instance of the PrivateEndpointConnectionListResultIterator type.
393func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator {
394	return PrivateEndpointConnectionListResultIterator{page: page}
395}
396
397// IsEmpty returns true if the ListResult contains no values.
398func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool {
399	return peclr.Value == nil || len(*peclr.Value) == 0
400}
401
402// hasNextLink returns true if the NextLink is not empty.
403func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool {
404	return peclr.NextLink != nil && len(*peclr.NextLink) != 0
405}
406
407// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results.
408// It returns nil if no more results exist.
409func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) {
410	if !peclr.hasNextLink() {
411		return nil, nil
412	}
413	return autorest.Prepare((&http.Request{}).WithContext(ctx),
414		autorest.AsJSON(),
415		autorest.AsGet(),
416		autorest.WithBaseURL(to.String(peclr.NextLink)))
417}
418
419// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values.
420type PrivateEndpointConnectionListResultPage struct {
421	fn    func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)
422	peclr PrivateEndpointConnectionListResult
423}
424
425// NextWithContext advances to the next page of values.  If there was an error making
426// the request the page does not advance and the error is returned.
427func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) {
428	if tracing.IsEnabled() {
429		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext")
430		defer func() {
431			sc := -1
432			if page.Response().Response.Response != nil {
433				sc = page.Response().Response.Response.StatusCode
434			}
435			tracing.EndSpan(ctx, sc, err)
436		}()
437	}
438	for {
439		next, err := page.fn(ctx, page.peclr)
440		if err != nil {
441			return err
442		}
443		page.peclr = next
444		if !next.hasNextLink() || !next.IsEmpty() {
445			break
446		}
447	}
448	return nil
449}
450
451// Next advances to the next page of values.  If there was an error making
452// the request the page does not advance and the error is returned.
453// Deprecated: Use NextWithContext() instead.
454func (page *PrivateEndpointConnectionListResultPage) Next() error {
455	return page.NextWithContext(context.Background())
456}
457
458// NotDone returns true if the page enumeration should be started or is not yet complete.
459func (page PrivateEndpointConnectionListResultPage) NotDone() bool {
460	return !page.peclr.IsEmpty()
461}
462
463// Response returns the raw server response from the last page request.
464func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult {
465	return page.peclr
466}
467
468// Values returns the slice of values for the current page or nil if there are no values.
469func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection {
470	if page.peclr.IsEmpty() {
471		return nil
472	}
473	return *page.peclr.Value
474}
475
476// Creates a new instance of the PrivateEndpointConnectionListResultPage type.
477func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage {
478	return PrivateEndpointConnectionListResultPage{
479		fn:    getNextPage,
480		peclr: cur,
481	}
482}
483
484// PrivateEndpointConnectionProperties describes the properties of an existing Private Endpoint connection
485// to the Azure Cognitive Search service.
486type PrivateEndpointConnectionProperties struct {
487	// PrivateEndpoint - The private endpoint resource from Microsoft.Network provider.
488	PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"`
489	// PrivateLinkServiceConnectionState - Describes the current state of an existing Private Link Service connection to the Azure Private Endpoint.
490	PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"`
491}
492
493// PrivateEndpointConnectionPropertiesPrivateEndpoint the private endpoint resource from Microsoft.Network
494// provider.
495type PrivateEndpointConnectionPropertiesPrivateEndpoint struct {
496	// ID - The resource id of the private endpoint resource from Microsoft.Network provider.
497	ID *string `json:"id,omitempty"`
498}
499
500// PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState describes the current state of an
501// existing Private Link Service connection to the Azure Private Endpoint.
502type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct {
503	// Status - Status of the the private link service connection. Can be Pending, Approved, Rejected, or Disconnected. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected'
504	Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"`
505	// Description - The description for the private link service connection state.
506	Description *string `json:"description,omitempty"`
507	// ActionsRequired - A description of any extra actions that may be required.
508	ActionsRequired *string `json:"actionsRequired,omitempty"`
509}
510
511// PrivateLinkResource describes a supported private link resource for the Azure Cognitive Search service.
512type PrivateLinkResource struct {
513	// ID - READ-ONLY; The ID of the private link resource.
514	ID *string `json:"id,omitempty"`
515	// Name - READ-ONLY; The name of the private link resource.
516	Name *string `json:"name,omitempty"`
517	// Type - READ-ONLY; The resource type.
518	Type *string `json:"type,omitempty"`
519	// Properties - READ-ONLY; Describes the properties of a supported private link resource for the Azure Cognitive Search service.
520	Properties *PrivateLinkResourceProperties `json:"properties,omitempty"`
521}
522
523// PrivateLinkResourceProperties describes the properties of a supported private link resource for the
524// Azure Cognitive Search service.
525type PrivateLinkResourceProperties struct {
526	// GroupID - READ-ONLY; The group ID of the private link resource.
527	GroupID *string `json:"groupId,omitempty"`
528	// RequiredMembers - READ-ONLY; The list of required members of the private link resource.
529	RequiredMembers *[]string `json:"requiredMembers,omitempty"`
530	// RequiredZoneNames - READ-ONLY; The list of required DNS zone names of the private link resource.
531	RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"`
532}
533
534// PrivateLinkResourcesResult response containing a list of supported Private Link Resources.
535type PrivateLinkResourcesResult struct {
536	autorest.Response `json:"-"`
537	// Value - READ-ONLY; The list of supported Private Link Resources.
538	Value *[]PrivateLinkResource `json:"value,omitempty"`
539}
540
541// QueryKey describes an API key for a given Azure Cognitive Search service that has permissions for query
542// operations only.
543type QueryKey struct {
544	autorest.Response `json:"-"`
545	// Name - READ-ONLY; The name of the query API key; may be empty.
546	Name *string `json:"name,omitempty"`
547	// Key - READ-ONLY; The value of the query API key.
548	Key *string `json:"key,omitempty"`
549}
550
551// Resource base type for all Azure resources.
552type Resource struct {
553	// ID - READ-ONLY; The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
554	ID *string `json:"id,omitempty"`
555	// Name - READ-ONLY; The name of the resource.
556	Name *string `json:"name,omitempty"`
557	// Type - READ-ONLY; The resource type.
558	Type *string `json:"type,omitempty"`
559	// 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.
560	Location *string `json:"location,omitempty"`
561	// Tags - Tags to help categorize the resource in the Azure portal.
562	Tags map[string]*string `json:"tags"`
563	// Identity - The identity of the resource.
564	Identity *Identity `json:"identity,omitempty"`
565}
566
567// MarshalJSON is the custom marshaler for Resource.
568func (r Resource) MarshalJSON() ([]byte, error) {
569	objectMap := make(map[string]interface{})
570	if r.Location != nil {
571		objectMap["location"] = r.Location
572	}
573	if r.Tags != nil {
574		objectMap["tags"] = r.Tags
575	}
576	if r.Identity != nil {
577		objectMap["identity"] = r.Identity
578	}
579	return json.Marshal(objectMap)
580}
581
582// Service describes an Azure Cognitive Search service and its current state.
583type Service struct {
584	autorest.Response `json:"-"`
585	// ServiceProperties - Properties of the Search service.
586	*ServiceProperties `json:"properties,omitempty"`
587	// Sku - The SKU of the Search Service, which determines price tier and capacity limits. This property is required when creating a new Search Service.
588	Sku *Sku `json:"sku,omitempty"`
589	// ID - READ-ONLY; The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
590	ID *string `json:"id,omitempty"`
591	// Name - READ-ONLY; The name of the resource.
592	Name *string `json:"name,omitempty"`
593	// Type - READ-ONLY; The resource type.
594	Type *string `json:"type,omitempty"`
595	// 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.
596	Location *string `json:"location,omitempty"`
597	// Tags - Tags to help categorize the resource in the Azure portal.
598	Tags map[string]*string `json:"tags"`
599	// Identity - The identity of the resource.
600	Identity *Identity `json:"identity,omitempty"`
601}
602
603// MarshalJSON is the custom marshaler for Service.
604func (s Service) MarshalJSON() ([]byte, error) {
605	objectMap := make(map[string]interface{})
606	if s.ServiceProperties != nil {
607		objectMap["properties"] = s.ServiceProperties
608	}
609	if s.Sku != nil {
610		objectMap["sku"] = s.Sku
611	}
612	if s.Location != nil {
613		objectMap["location"] = s.Location
614	}
615	if s.Tags != nil {
616		objectMap["tags"] = s.Tags
617	}
618	if s.Identity != nil {
619		objectMap["identity"] = s.Identity
620	}
621	return json.Marshal(objectMap)
622}
623
624// UnmarshalJSON is the custom unmarshaler for Service struct.
625func (s *Service) UnmarshalJSON(body []byte) error {
626	var m map[string]*json.RawMessage
627	err := json.Unmarshal(body, &m)
628	if err != nil {
629		return err
630	}
631	for k, v := range m {
632		switch k {
633		case "properties":
634			if v != nil {
635				var serviceProperties ServiceProperties
636				err = json.Unmarshal(*v, &serviceProperties)
637				if err != nil {
638					return err
639				}
640				s.ServiceProperties = &serviceProperties
641			}
642		case "sku":
643			if v != nil {
644				var sku Sku
645				err = json.Unmarshal(*v, &sku)
646				if err != nil {
647					return err
648				}
649				s.Sku = &sku
650			}
651		case "id":
652			if v != nil {
653				var ID string
654				err = json.Unmarshal(*v, &ID)
655				if err != nil {
656					return err
657				}
658				s.ID = &ID
659			}
660		case "name":
661			if v != nil {
662				var name string
663				err = json.Unmarshal(*v, &name)
664				if err != nil {
665					return err
666				}
667				s.Name = &name
668			}
669		case "type":
670			if v != nil {
671				var typeVar string
672				err = json.Unmarshal(*v, &typeVar)
673				if err != nil {
674					return err
675				}
676				s.Type = &typeVar
677			}
678		case "location":
679			if v != nil {
680				var location string
681				err = json.Unmarshal(*v, &location)
682				if err != nil {
683					return err
684				}
685				s.Location = &location
686			}
687		case "tags":
688			if v != nil {
689				var tags map[string]*string
690				err = json.Unmarshal(*v, &tags)
691				if err != nil {
692					return err
693				}
694				s.Tags = tags
695			}
696		case "identity":
697			if v != nil {
698				var identity Identity
699				err = json.Unmarshal(*v, &identity)
700				if err != nil {
701					return err
702				}
703				s.Identity = &identity
704			}
705		}
706	}
707
708	return nil
709}
710
711// ServiceListResult response containing a list of Azure Cognitive Search services.
712type ServiceListResult struct {
713	autorest.Response `json:"-"`
714	// Value - READ-ONLY; The list of Search services.
715	Value *[]Service `json:"value,omitempty"`
716	// NextLink - READ-ONLY; Request URL that can be used to query next page of search services. Returned when the total number of requested search services exceed maximum page size.
717	NextLink *string `json:"nextLink,omitempty"`
718}
719
720// ServiceListResultIterator provides access to a complete listing of Service values.
721type ServiceListResultIterator struct {
722	i    int
723	page ServiceListResultPage
724}
725
726// NextWithContext advances to the next value.  If there was an error making
727// the request the iterator does not advance and the error is returned.
728func (iter *ServiceListResultIterator) NextWithContext(ctx context.Context) (err error) {
729	if tracing.IsEnabled() {
730		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultIterator.NextWithContext")
731		defer func() {
732			sc := -1
733			if iter.Response().Response.Response != nil {
734				sc = iter.Response().Response.Response.StatusCode
735			}
736			tracing.EndSpan(ctx, sc, err)
737		}()
738	}
739	iter.i++
740	if iter.i < len(iter.page.Values()) {
741		return nil
742	}
743	err = iter.page.NextWithContext(ctx)
744	if err != nil {
745		iter.i--
746		return err
747	}
748	iter.i = 0
749	return nil
750}
751
752// Next advances to the next value.  If there was an error making
753// the request the iterator does not advance and the error is returned.
754// Deprecated: Use NextWithContext() instead.
755func (iter *ServiceListResultIterator) Next() error {
756	return iter.NextWithContext(context.Background())
757}
758
759// NotDone returns true if the enumeration should be started or is not yet complete.
760func (iter ServiceListResultIterator) NotDone() bool {
761	return iter.page.NotDone() && iter.i < len(iter.page.Values())
762}
763
764// Response returns the raw server response from the last page request.
765func (iter ServiceListResultIterator) Response() ServiceListResult {
766	return iter.page.Response()
767}
768
769// Value returns the current value or a zero-initialized value if the
770// iterator has advanced beyond the end of the collection.
771func (iter ServiceListResultIterator) Value() Service {
772	if !iter.page.NotDone() {
773		return Service{}
774	}
775	return iter.page.Values()[iter.i]
776}
777
778// Creates a new instance of the ServiceListResultIterator type.
779func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator {
780	return ServiceListResultIterator{page: page}
781}
782
783// IsEmpty returns true if the ListResult contains no values.
784func (slr ServiceListResult) IsEmpty() bool {
785	return slr.Value == nil || len(*slr.Value) == 0
786}
787
788// hasNextLink returns true if the NextLink is not empty.
789func (slr ServiceListResult) hasNextLink() bool {
790	return slr.NextLink != nil && len(*slr.NextLink) != 0
791}
792
793// serviceListResultPreparer prepares a request to retrieve the next set of results.
794// It returns nil if no more results exist.
795func (slr ServiceListResult) serviceListResultPreparer(ctx context.Context) (*http.Request, error) {
796	if !slr.hasNextLink() {
797		return nil, nil
798	}
799	return autorest.Prepare((&http.Request{}).WithContext(ctx),
800		autorest.AsJSON(),
801		autorest.AsGet(),
802		autorest.WithBaseURL(to.String(slr.NextLink)))
803}
804
805// ServiceListResultPage contains a page of Service values.
806type ServiceListResultPage struct {
807	fn  func(context.Context, ServiceListResult) (ServiceListResult, error)
808	slr ServiceListResult
809}
810
811// NextWithContext advances to the next page of values.  If there was an error making
812// the request the page does not advance and the error is returned.
813func (page *ServiceListResultPage) NextWithContext(ctx context.Context) (err error) {
814	if tracing.IsEnabled() {
815		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultPage.NextWithContext")
816		defer func() {
817			sc := -1
818			if page.Response().Response.Response != nil {
819				sc = page.Response().Response.Response.StatusCode
820			}
821			tracing.EndSpan(ctx, sc, err)
822		}()
823	}
824	for {
825		next, err := page.fn(ctx, page.slr)
826		if err != nil {
827			return err
828		}
829		page.slr = next
830		if !next.hasNextLink() || !next.IsEmpty() {
831			break
832		}
833	}
834	return nil
835}
836
837// Next advances to the next page of values.  If there was an error making
838// the request the page does not advance and the error is returned.
839// Deprecated: Use NextWithContext() instead.
840func (page *ServiceListResultPage) Next() error {
841	return page.NextWithContext(context.Background())
842}
843
844// NotDone returns true if the page enumeration should be started or is not yet complete.
845func (page ServiceListResultPage) NotDone() bool {
846	return !page.slr.IsEmpty()
847}
848
849// Response returns the raw server response from the last page request.
850func (page ServiceListResultPage) Response() ServiceListResult {
851	return page.slr
852}
853
854// Values returns the slice of values for the current page or nil if there are no values.
855func (page ServiceListResultPage) Values() []Service {
856	if page.slr.IsEmpty() {
857		return nil
858	}
859	return *page.slr.Value
860}
861
862// Creates a new instance of the ServiceListResultPage type.
863func NewServiceListResultPage(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage {
864	return ServiceListResultPage{
865		fn:  getNextPage,
866		slr: cur,
867	}
868}
869
870// ServiceProperties properties of the Search service.
871type ServiceProperties struct {
872	// 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.
873	ReplicaCount *int32 `json:"replicaCount,omitempty"`
874	// 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.
875	PartitionCount *int32 `json:"partitionCount,omitempty"`
876	// 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'
877	HostingMode HostingMode `json:"hostingMode,omitempty"`
878	// PublicNetworkAccess - This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Possible values include: 'Enabled', 'Disabled'
879	PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"`
880	// 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'
881	Status ServiceStatus `json:"status,omitempty"`
882	// StatusDetails - READ-ONLY; The details of the Search service status.
883	StatusDetails *string `json:"statusDetails,omitempty"`
884	// 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'
885	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
886	// NetworkRuleSet - Network specific rules that determine how the Azure Cognitive Search service may be reached.
887	NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"`
888	// PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections to the Azure Cognitive Search service.
889	PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"`
890}
891
892// MarshalJSON is the custom marshaler for ServiceProperties.
893func (sp ServiceProperties) MarshalJSON() ([]byte, error) {
894	objectMap := make(map[string]interface{})
895	if sp.ReplicaCount != nil {
896		objectMap["replicaCount"] = sp.ReplicaCount
897	}
898	if sp.PartitionCount != nil {
899		objectMap["partitionCount"] = sp.PartitionCount
900	}
901	if sp.HostingMode != "" {
902		objectMap["hostingMode"] = sp.HostingMode
903	}
904	if sp.PublicNetworkAccess != "" {
905		objectMap["publicNetworkAccess"] = sp.PublicNetworkAccess
906	}
907	if sp.NetworkRuleSet != nil {
908		objectMap["networkRuleSet"] = sp.NetworkRuleSet
909	}
910	return json.Marshal(objectMap)
911}
912
913// ServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
914// operation.
915type ServicesCreateOrUpdateFuture struct {
916	azure.FutureAPI
917	// Result returns the result of the asynchronous operation.
918	// If the operation has not completed it will return an error.
919	Result func(ServicesClient) (Service, error)
920}
921
922// Sku defines the SKU of an Azure Cognitive Search Service, which determines price tier and capacity
923// limits.
924type Sku struct {
925	// 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'
926	Name SkuName `json:"name,omitempty"`
927}
928