diff --git a/services/search/mgmt/2020-08-01/search/adminkeys.go b/services/search/mgmt/2020-08-01/search/adminkeys.go new file mode 100644 index 000000000000..2f55af60aed7 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/adminkeys.go @@ -0,0 +1,211 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// AdminKeysClient is the client that can be used to manage Azure Cognitive Search services and API keys. +type AdminKeysClient struct { + BaseClient +} + +// NewAdminKeysClient creates an instance of the AdminKeysClient client. +func NewAdminKeysClient(subscriptionID string) AdminKeysClient { + return NewAdminKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAdminKeysClientWithBaseURI creates an instance of the AdminKeysClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAdminKeysClientWithBaseURI(baseURI string, subscriptionID string) AdminKeysClient { + return AdminKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the primary and secondary admin API keys for the specified Azure Cognitive Search service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client AdminKeysClient) Get(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result AdminKeyResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdminKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdminKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listAdminKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AdminKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdminKeysClient) GetResponder(resp *http.Response) (result AdminKeyResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Regenerate regenerates either the primary or secondary admin API key. You can only regenerate one key at a time. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// keyKind - specifies which key to regenerate. Valid values include 'primary' and 'secondary'. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client AdminKeysClient) Regenerate(ctx context.Context, resourceGroupName string, searchServiceName string, keyKind AdminKeyKind, clientRequestID *uuid.UUID) (result AdminKeyResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdminKeysClient.Regenerate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RegeneratePreparer(ctx, resourceGroupName, searchServiceName, keyKind, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Regenerate", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Regenerate", resp, "Failure sending request") + return + } + + result, err = client.RegenerateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "Regenerate", resp, "Failure responding to request") + } + + return +} + +// RegeneratePreparer prepares the Regenerate request. +func (client AdminKeysClient) RegeneratePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, keyKind AdminKeyKind, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyKind": autorest.Encode("path", keyKind), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/regenerateAdminKey/{keyKind}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateSender sends the Regenerate request. The method will close the +// http.Response Body if it receives an error. +func (client AdminKeysClient) RegenerateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateResponder handles the response to the Regenerate request. The method always +// closes the http.Response Body. +func (client AdminKeysClient) RegenerateResponder(resp *http.Response) (result AdminKeyResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/search/mgmt/2020-08-01/search/client.go b/services/search/mgmt/2020-08-01/search/client.go new file mode 100644 index 000000000000..6a8030c25b0a --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/client.go @@ -0,0 +1,52 @@ +// Package search implements the Azure ARM Search service API version 2020-08-01. +// +// Client that can be used to manage Azure Cognitive Search services and API keys. +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Search + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Search. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/search/mgmt/2020-08-01/search/enums.go b/services/search/mgmt/2020-08-01/search/enums.go new file mode 100644 index 000000000000..6cf9d7fda720 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/enums.go @@ -0,0 +1,236 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AdminKeyKind enumerates the values for admin key kind. +type AdminKeyKind string + +const ( + // Primary ... + Primary AdminKeyKind = "primary" + // Secondary ... + Secondary AdminKeyKind = "secondary" +) + +// PossibleAdminKeyKindValues returns an array of possible values for the AdminKeyKind const type. +func PossibleAdminKeyKindValues() []AdminKeyKind { + return []AdminKeyKind{Primary, Secondary} +} + +// HostingMode enumerates the values for hosting mode. +type HostingMode string + +const ( + // Default ... + Default HostingMode = "default" + // HighDensity ... + HighDensity HostingMode = "highDensity" +) + +// PossibleHostingModeValues returns an array of possible values for the HostingMode const type. +func PossibleHostingModeValues() []HostingMode { + return []HostingMode{Default, HighDensity} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // None ... + None IdentityType = "None" + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{None, SystemAssigned} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateLinkServiceConnectionStatus = "Approved" + // Disconnected ... + Disconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // Pending ... + Pending PrivateLinkServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{Approved, Disconnected, Pending, Rejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Failed ... + Failed ProvisioningState = "failed" + // Provisioning ... + Provisioning ProvisioningState = "provisioning" + // Succeeded ... + Succeeded ProvisioningState = "succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Failed, Provisioning, Succeeded} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "disabled" + // Enabled ... + Enabled PublicNetworkAccess = "enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} + +// ServiceStatus enumerates the values for service status. +type ServiceStatus string + +const ( + // ServiceStatusDegraded ... + ServiceStatusDegraded ServiceStatus = "degraded" + // ServiceStatusDeleting ... + ServiceStatusDeleting ServiceStatus = "deleting" + // ServiceStatusDisabled ... + ServiceStatusDisabled ServiceStatus = "disabled" + // ServiceStatusError ... + ServiceStatusError ServiceStatus = "error" + // ServiceStatusProvisioning ... + ServiceStatusProvisioning ServiceStatus = "provisioning" + // ServiceStatusRunning ... + ServiceStatusRunning ServiceStatus = "running" +) + +// PossibleServiceStatusValues returns an array of possible values for the ServiceStatus const type. +func PossibleServiceStatusValues() []ServiceStatus { + return []ServiceStatus{ServiceStatusDegraded, ServiceStatusDeleting, ServiceStatusDisabled, ServiceStatusError, ServiceStatusProvisioning, ServiceStatusRunning} +} + +// SharedPrivateLinkResourceAsyncOperationResult enumerates the values for shared private link resource async +// operation result. +type SharedPrivateLinkResourceAsyncOperationResult string + +const ( + // SharedPrivateLinkResourceAsyncOperationResultFailed ... + SharedPrivateLinkResourceAsyncOperationResultFailed SharedPrivateLinkResourceAsyncOperationResult = "Failed" + // SharedPrivateLinkResourceAsyncOperationResultRunning ... + SharedPrivateLinkResourceAsyncOperationResultRunning SharedPrivateLinkResourceAsyncOperationResult = "Running" + // SharedPrivateLinkResourceAsyncOperationResultSucceeded ... + SharedPrivateLinkResourceAsyncOperationResultSucceeded SharedPrivateLinkResourceAsyncOperationResult = "Succeeded" +) + +// PossibleSharedPrivateLinkResourceAsyncOperationResultValues returns an array of possible values for the SharedPrivateLinkResourceAsyncOperationResult const type. +func PossibleSharedPrivateLinkResourceAsyncOperationResultValues() []SharedPrivateLinkResourceAsyncOperationResult { + return []SharedPrivateLinkResourceAsyncOperationResult{SharedPrivateLinkResourceAsyncOperationResultFailed, SharedPrivateLinkResourceAsyncOperationResultRunning, SharedPrivateLinkResourceAsyncOperationResultSucceeded} +} + +// SharedPrivateLinkResourceProvisioningState enumerates the values for shared private link resource +// provisioning state. +type SharedPrivateLinkResourceProvisioningState string + +const ( + // SharedPrivateLinkResourceProvisioningStateDeleting ... + SharedPrivateLinkResourceProvisioningStateDeleting SharedPrivateLinkResourceProvisioningState = "Deleting" + // SharedPrivateLinkResourceProvisioningStateFailed ... + SharedPrivateLinkResourceProvisioningStateFailed SharedPrivateLinkResourceProvisioningState = "Failed" + // SharedPrivateLinkResourceProvisioningStateIncomplete ... + SharedPrivateLinkResourceProvisioningStateIncomplete SharedPrivateLinkResourceProvisioningState = "Incomplete" + // SharedPrivateLinkResourceProvisioningStateSucceeded ... + SharedPrivateLinkResourceProvisioningStateSucceeded SharedPrivateLinkResourceProvisioningState = "Succeeded" + // SharedPrivateLinkResourceProvisioningStateUpdating ... + SharedPrivateLinkResourceProvisioningStateUpdating SharedPrivateLinkResourceProvisioningState = "Updating" +) + +// PossibleSharedPrivateLinkResourceProvisioningStateValues returns an array of possible values for the SharedPrivateLinkResourceProvisioningState const type. +func PossibleSharedPrivateLinkResourceProvisioningStateValues() []SharedPrivateLinkResourceProvisioningState { + return []SharedPrivateLinkResourceProvisioningState{SharedPrivateLinkResourceProvisioningStateDeleting, SharedPrivateLinkResourceProvisioningStateFailed, SharedPrivateLinkResourceProvisioningStateIncomplete, SharedPrivateLinkResourceProvisioningStateSucceeded, SharedPrivateLinkResourceProvisioningStateUpdating} +} + +// SharedPrivateLinkResourceStatus enumerates the values for shared private link resource status. +type SharedPrivateLinkResourceStatus string + +const ( + // SharedPrivateLinkResourceStatusApproved ... + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + // SharedPrivateLinkResourceStatusDisconnected ... + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + // SharedPrivateLinkResourceStatusPending ... + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + // SharedPrivateLinkResourceStatusRejected ... + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" +) + +// PossibleSharedPrivateLinkResourceStatusValues returns an array of possible values for the SharedPrivateLinkResourceStatus const type. +func PossibleSharedPrivateLinkResourceStatusValues() []SharedPrivateLinkResourceStatus { + return []SharedPrivateLinkResourceStatus{SharedPrivateLinkResourceStatusApproved, SharedPrivateLinkResourceStatusDisconnected, SharedPrivateLinkResourceStatusPending, SharedPrivateLinkResourceStatusRejected} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // Basic ... + Basic SkuName = "basic" + // Free ... + Free SkuName = "free" + // Standard ... + Standard SkuName = "standard" + // Standard2 ... + Standard2 SkuName = "standard2" + // Standard3 ... + Standard3 SkuName = "standard3" + // StorageOptimizedL1 ... + StorageOptimizedL1 SkuName = "storage_optimized_l1" + // StorageOptimizedL2 ... + StorageOptimizedL2 SkuName = "storage_optimized_l2" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{Basic, Free, Standard, Standard2, Standard3, StorageOptimizedL1, StorageOptimizedL2} +} + +// UnavailableNameReason enumerates the values for unavailable name reason. +type UnavailableNameReason string + +const ( + // AlreadyExists ... + AlreadyExists UnavailableNameReason = "AlreadyExists" + // Invalid ... + Invalid UnavailableNameReason = "Invalid" +) + +// PossibleUnavailableNameReasonValues returns an array of possible values for the UnavailableNameReason const type. +func PossibleUnavailableNameReasonValues() []UnavailableNameReason { + return []UnavailableNameReason{AlreadyExists, Invalid} +} diff --git a/services/search/mgmt/2020-08-01/search/models.go b/services/search/mgmt/2020-08-01/search/models.go new file mode 100644 index 000000000000..136d8e2f1749 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/models.go @@ -0,0 +1,1395 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2020-08-01/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"` +} + +// AsyncOperationResult the details of a long running asynchronous shared private link resource operation +type AsyncOperationResult struct { + // Status - The current status of the long running asynchronous shared private link resource operation. Possible values include: 'SharedPrivateLinkResourceAsyncOperationResultRunning', 'SharedPrivateLinkResourceAsyncOperationResultSucceeded', 'SharedPrivateLinkResourceAsyncOperationResultFailed' + Status SharedPrivateLinkResourceAsyncOperationResult `json:"status,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// 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"` +} + +// 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) +} + +// IPRule the IP restriction rule of the Azure Cognitive Search service. +type IPRule struct { + // 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. + Value *string `json:"value,omitempty"` +} + +// 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"` + // 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. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListQueryKeysResultIterator provides access to a complete listing of QueryKey values. +type ListQueryKeysResultIterator struct { + i int + page ListQueryKeysResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ListQueryKeysResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListQueryKeysResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ListQueryKeysResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListQueryKeysResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ListQueryKeysResultIterator) Response() ListQueryKeysResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ListQueryKeysResultIterator) Value() QueryKey { + if !iter.page.NotDone() { + return QueryKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ListQueryKeysResultIterator type. +func NewListQueryKeysResultIterator(page ListQueryKeysResultPage) ListQueryKeysResultIterator { + return ListQueryKeysResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lqkr ListQueryKeysResult) IsEmpty() bool { + return lqkr.Value == nil || len(*lqkr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lqkr ListQueryKeysResult) hasNextLink() bool { + return lqkr.NextLink != nil && len(*lqkr.NextLink) != 0 +} + +// listQueryKeysResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lqkr ListQueryKeysResult) listQueryKeysResultPreparer(ctx context.Context) (*http.Request, error) { + if !lqkr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lqkr.NextLink))) +} + +// ListQueryKeysResultPage contains a page of QueryKey values. +type ListQueryKeysResultPage struct { + fn func(context.Context, ListQueryKeysResult) (ListQueryKeysResult, error) + lqkr ListQueryKeysResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ListQueryKeysResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListQueryKeysResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.lqkr) + if err != nil { + return err + } + page.lqkr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ListQueryKeysResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListQueryKeysResultPage) NotDone() bool { + return !page.lqkr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListQueryKeysResultPage) Response() ListQueryKeysResult { + return page.lqkr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListQueryKeysResultPage) Values() []QueryKey { + if page.lqkr.IsEmpty() { + return nil + } + return *page.lqkr.Value +} + +// Creates a new instance of the ListQueryKeysResultPage type. +func NewListQueryKeysResultPage(cur ListQueryKeysResult, getNextPage func(context.Context, ListQueryKeysResult) (ListQueryKeysResult, error)) ListQueryKeysResultPage { + return ListQueryKeysResultPage{ + fn: getNextPage, + lqkr: cur, + } +} + +// NetworkRuleSet network specific rules that determine how the Azure Cognitive Search service may be +// reached. +type NetworkRuleSet struct { + // 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. + IPRules *[]IPRule `json:"ipRules,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// PrivateEndpointConnection describes an existing Private Endpoint connection to the Azure Cognitive +// Search service. +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // Properties - Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.Properties != nil { + objectMap["properties"] = pec.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResult response containing a list of Private Endpoint connections. +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of Private Endpoint connections. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // 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. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties describes the properties of an existing Private Endpoint connection +// to the Azure Cognitive Search service. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The private endpoint resource from Microsoft.Network provider. + PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Describes the current state of an existing Private Link Service connection to the Azure Private Endpoint. + PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// PrivateEndpointConnectionPropertiesPrivateEndpoint the private endpoint resource from Microsoft.Network +// provider. +type PrivateEndpointConnectionPropertiesPrivateEndpoint struct { + // ID - The resource id of the private endpoint resource from Microsoft.Network provider. + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState describes the current state of an +// existing Private Link Service connection to the Azure Private Endpoint. +type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct { + // Status - Status of the the private link service connection. Can be Pending, Approved, Rejected, or Disconnected. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The description for the private link service connection state. + Description *string `json:"description,omitempty"` + // ActionsRequired - A description of any extra actions that may be required. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// PrivateLinkResource describes a supported private link resource for the Azure Cognitive Search service. +type PrivateLinkResource struct { + // Properties - READ-ONLY; Describes the properties of a supported private link resource for the Azure Cognitive Search service. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// PrivateLinkResourceProperties describes the properties of a supported private link resource for the +// Azure Cognitive Search service. For a given API version, this represents the 'supported' groupIds when +// creating a shared private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The group ID of the private link resource. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The list of required members of the private link resource. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The list of required DNS zone names of the private link resource. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + // ShareablePrivateLinkResourceTypes - READ-ONLY; The list of resources that are onboarded to private link service, that are supported by Azure Cognitive Search. + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} + +// PrivateLinkResourcesResult response containing a list of supported Private Link Resources. +type PrivateLinkResourcesResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of supported Private Link Resources. + Value *[]PrivateLinkResource `json:"value,omitempty"` +} + +// ProxyResource the resource model definition for an Azure Resource Manager proxy resource. It will have +// everything other than required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// 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"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// 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"` + // Identity - The identity of the resource. + Identity *Identity `json:"identity,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,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.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + 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 "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + 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 + } + } + } + + 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"` + // 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. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceListResultIterator provides access to a complete listing of Service values. +type ServiceListResultIterator struct { + i int + page ServiceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServiceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServiceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServiceListResultIterator) Response() ServiceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServiceListResultIterator) Value() Service { + if !iter.page.NotDone() { + return Service{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceListResultIterator type. +func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator { + return ServiceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServiceListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServiceListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serviceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServiceListResult) serviceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServiceListResultPage contains a page of Service values. +type ServiceListResultPage struct { + fn func(context.Context, ServiceListResult) (ServiceListResult, error) + slr ServiceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServiceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceListResultPage) Response() ServiceListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceListResultPage) Values() []Service { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServiceListResultPage type. +func NewServiceListResultPage(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return ServiceListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// 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"` + // 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' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,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"` + // NetworkRuleSet - Network specific rules that determine how the Azure Cognitive Search service may be reached. + NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + // PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections to the Azure Cognitive Search service. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // SharedPrivateLinkResources - READ-ONLY; The list of shared private link resources managed by the Azure Cognitive Search service. + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,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 + } + if sp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = sp.PublicNetworkAccess + } + if sp.NetworkRuleSet != nil { + objectMap["networkRuleSet"] = sp.NetworkRuleSet + } + return json.Marshal(objectMap) +} + +// ServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServicesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// ServiceUpdate the parameters used to update an Azure Cognitive Search service. +type ServiceUpdate struct { + // 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"` + // 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"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceUpdate. +func (su ServiceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.ServiceProperties != nil { + objectMap["properties"] = su.ServiceProperties + } + if su.Sku != nil { + objectMap["sku"] = su.Sku + } + if su.Location != nil { + objectMap["location"] = su.Location + } + if su.Tags != nil { + objectMap["tags"] = su.Tags + } + if su.Identity != nil { + objectMap["identity"] = su.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceUpdate struct. +func (su *ServiceUpdate) 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 + } + su.ServiceProperties = &serviceProperties + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + su.Sku = &sku + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + su.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + su.Tags = tags + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + su.Identity = &identity + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + su.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + su.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + su.Type = &typeVar + } + } + } + + return nil +} + +// ShareablePrivateLinkResourceProperties describes the properties of a resource type that has been +// onboarded to private link service, supported by Azure Cognitive Search. +type ShareablePrivateLinkResourceProperties struct { + // Type - READ-ONLY; The resource provider type for the resource that has been onboarded to private link service, supported by Azure Cognitive Search. + Type *string `json:"type,omitempty"` + // GroupID - READ-ONLY; The resource provider group id for the resource that has been onboarded to private link service, supported by Azure Cognitive Search. + GroupID *string `json:"groupId,omitempty"` + // Description - READ-ONLY; The description of the resource type that has been onboarded to private link service, supported by Azure Cognitive Search. + Description *string `json:"description,omitempty"` +} + +// ShareablePrivateLinkResourceType describes an resource type that has been onboarded to private link +// service, supported by Azure Cognitive Search. +type ShareablePrivateLinkResourceType struct { + // Name - READ-ONLY; The name of the resource type that has been onboarded to private link service, supported by Azure Cognitive Search. + Name *string `json:"name,omitempty"` + // Properties - READ-ONLY; Describes the properties of a resource type that has been onboarded to private link service, supported by Azure Cognitive Search. + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// SharedPrivateLinkResource describes a Shared Private Link Resource managed by the Azure Cognitive Search +// service. +type SharedPrivateLinkResource struct { + autorest.Response `json:"-"` + // Properties - Describes the properties of a Shared Private Link Resource managed by the Azure Cognitive Search service. + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResource. +func (splr SharedPrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splr.Properties != nil { + objectMap["properties"] = splr.Properties + } + return json.Marshal(objectMap) +} + +// SharedPrivateLinkResourceListResult response containing a list of Shared Private Link Resources. +type SharedPrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of Shared Private Link Resources. + Value *[]SharedPrivateLinkResource `json:"value,omitempty"` + // NextLink - The URL to get the next set of shared private link resources, if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResourceListResult. +func (splrlr SharedPrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splrlr.NextLink != nil { + objectMap["nextLink"] = splrlr.NextLink + } + return json.Marshal(objectMap) +} + +// SharedPrivateLinkResourceListResultIterator provides access to a complete listing of +// SharedPrivateLinkResource values. +type SharedPrivateLinkResourceListResultIterator struct { + i int + page SharedPrivateLinkResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedPrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedPrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedPrivateLinkResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedPrivateLinkResourceListResultIterator) Response() SharedPrivateLinkResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedPrivateLinkResourceListResultIterator) Value() SharedPrivateLinkResource { + if !iter.page.NotDone() { + return SharedPrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedPrivateLinkResourceListResultIterator type. +func NewSharedPrivateLinkResourceListResultIterator(page SharedPrivateLinkResourceListResultPage) SharedPrivateLinkResourceListResultIterator { + return SharedPrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (splrlr SharedPrivateLinkResourceListResult) IsEmpty() bool { + return splrlr.Value == nil || len(*splrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splrlr SharedPrivateLinkResourceListResult) hasNextLink() bool { + return splrlr.NextLink != nil && len(*splrlr.NextLink) != 0 +} + +// sharedPrivateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (splrlr SharedPrivateLinkResourceListResult) sharedPrivateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !splrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(splrlr.NextLink))) +} + +// SharedPrivateLinkResourceListResultPage contains a page of SharedPrivateLinkResource values. +type SharedPrivateLinkResourceListResultPage struct { + fn func(context.Context, SharedPrivateLinkResourceListResult) (SharedPrivateLinkResourceListResult, error) + splrlr SharedPrivateLinkResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedPrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.splrlr) + if err != nil { + return err + } + page.splrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedPrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedPrivateLinkResourceListResultPage) NotDone() bool { + return !page.splrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedPrivateLinkResourceListResultPage) Response() SharedPrivateLinkResourceListResult { + return page.splrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedPrivateLinkResourceListResultPage) Values() []SharedPrivateLinkResource { + if page.splrlr.IsEmpty() { + return nil + } + return *page.splrlr.Value +} + +// Creates a new instance of the SharedPrivateLinkResourceListResultPage type. +func NewSharedPrivateLinkResourceListResultPage(cur SharedPrivateLinkResourceListResult, getNextPage func(context.Context, SharedPrivateLinkResourceListResult) (SharedPrivateLinkResourceListResult, error)) SharedPrivateLinkResourceListResultPage { + return SharedPrivateLinkResourceListResultPage{ + fn: getNextPage, + splrlr: cur, + } +} + +// SharedPrivateLinkResourceProperties describes the properties of an existing Shared Private Link Resource +// managed by the Azure Cognitive Search service. +type SharedPrivateLinkResourceProperties struct { + // PrivateLinkResourceID - The resource id of the resource the shared private link resource is for. + PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"` + // GroupID - The group id from the provider of resource the shared private link resource is for. + GroupID *string `json:"groupId,omitempty"` + // RequestMessage - The request message for requesting approval of the shared private link resource. + RequestMessage *string `json:"requestMessage,omitempty"` + // ResourceRegion - Optional. Can be used to specify the Azure Resource Manager location of the resource to which a shared private link is to be created. This is only required for those resources whose DNS configuration are regional (such as Azure Kubernetes Service). + ResourceRegion *string `json:"resourceRegion,omitempty"` + // Status - Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. Possible values include: 'SharedPrivateLinkResourceStatusPending', 'SharedPrivateLinkResourceStatusApproved', 'SharedPrivateLinkResourceStatusRejected', 'SharedPrivateLinkResourceStatusDisconnected' + Status SharedPrivateLinkResourceStatus `json:"status,omitempty"` + // ProvisioningState - The provisioning state of the shared private link resource. Can be Updating, Deleting, Failed, Succeeded or Incomplete. Possible values include: 'SharedPrivateLinkResourceProvisioningStateUpdating', 'SharedPrivateLinkResourceProvisioningStateDeleting', 'SharedPrivateLinkResourceProvisioningStateFailed', 'SharedPrivateLinkResourceProvisioningStateSucceeded', 'SharedPrivateLinkResourceProvisioningStateIncomplete' + ProvisioningState SharedPrivateLinkResourceProvisioningState `json:"provisioningState,omitempty"` +} + +// SharedPrivateLinkResourcesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SharedPrivateLinkResourcesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SharedPrivateLinkResourcesCreateOrUpdateFuture) Result(client SharedPrivateLinkResourcesClient) (splr SharedPrivateLinkResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("search.SharedPrivateLinkResourcesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if splr.Response.Response, err = future.GetResult(sender); err == nil && splr.Response.Response.StatusCode != http.StatusNoContent { + splr, err = client.CreateOrUpdateResponder(splr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", splr.Response.Response, "Failure responding to request") + } + } + return +} + +// SharedPrivateLinkResourcesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SharedPrivateLinkResourcesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SharedPrivateLinkResourcesDeleteFuture) Result(client SharedPrivateLinkResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("search.SharedPrivateLinkResourcesDeleteFuture") + return + } + ar.Response = future.Response() + 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"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} diff --git a/services/search/mgmt/2020-08-01/search/operations.go b/services/search/mgmt/2020-08-01/search/operations.go new file mode 100644 index 000000000000..130547380797 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/operations.go @@ -0,0 +1,108 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client that can be used to manage Azure Cognitive Search services and API keys. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the Microsoft.Search provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "search.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Search/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/search/mgmt/2020-08-01/search/privateendpointconnections.go b/services/search/mgmt/2020-08-01/search/privateendpointconnections.go new file mode 100644 index 000000000000..6d21653aadc3 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/privateendpointconnections.go @@ -0,0 +1,430 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// PrivateEndpointConnectionsClient is the client that can be used to manage Azure Cognitive Search services and API +// keys. +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete disconnects the private endpoint connection and deletes it from the search service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// privateEndpointConnectionName - the name of the private endpoint connection to the Azure Cognitive Search +// service with the specified resource group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, searchServiceName, privateEndpointConnectionName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the private endpoint connection to the search service in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// privateEndpointConnectionName - the name of the private endpoint connection to the Azure Cognitive Search +// service with the specified resource group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, searchServiceName, privateEndpointConnectionName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets a list of all private endpoint connections in the given service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client PrivateEndpointConnectionsClient) ListByService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByService") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "ListByService", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "ListByService", resp, "Failure responding to request") + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByServiceNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, searchServiceName, clientRequestID) + return +} + +// Update updates a Private Endpoint connection to the search service in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// privateEndpointConnectionName - the name of the private endpoint connection to the Azure Cognitive Search +// service with the specified resource group. +// privateEndpointConnection - the definition of the private endpoint connection to update. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client PrivateEndpointConnectionsClient) Update(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, clientRequestID *uuid.UUID) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, searchServiceName, privateEndpointConnectionName, privateEndpointConnection, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateEndpointConnectionsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/search/mgmt/2020-08-01/search/privatelinkresources.go b/services/search/mgmt/2020-08-01/search/privatelinkresources.go new file mode 100644 index 000000000000..068980c2a71d --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/privatelinkresources.go @@ -0,0 +1,127 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// PrivateLinkResourcesClient is the client that can be used to manage Azure Cognitive Search services and API keys. +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListSupported gets a list of all supported private link resource types for the given service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client PrivateLinkResourcesClient) ListSupported(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result PrivateLinkResourcesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListSupported") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListSupportedPreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", nil, "Failure preparing request") + return + } + + resp, err := client.ListSupportedSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure sending request") + return + } + + result, err = client.ListSupportedResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure responding to request") + } + + return +} + +// ListSupportedPreparer prepares the ListSupported request. +func (client PrivateLinkResourcesClient) ListSupportedPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSupportedSender sends the ListSupported request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListSupportedSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSupportedResponder handles the response to the ListSupported request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListSupportedResponder(resp *http.Response) (result PrivateLinkResourcesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/search/mgmt/2020-08-01/search/querykeys.go b/services/search/mgmt/2020-08-01/search/querykeys.go new file mode 100644 index 000000000000..366c45e99418 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/querykeys.go @@ -0,0 +1,337 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// QueryKeysClient is the client that can be used to manage Azure Cognitive Search services and API keys. +type QueryKeysClient struct { + BaseClient +} + +// NewQueryKeysClient creates an instance of the QueryKeysClient client. +func NewQueryKeysClient(subscriptionID string) QueryKeysClient { + return NewQueryKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQueryKeysClientWithBaseURI creates an instance of the QueryKeysClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewQueryKeysClientWithBaseURI(baseURI string, subscriptionID string) QueryKeysClient { + return QueryKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create generates a new query key for the specified search service. You can create up to 50 query keys per service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// name - the name of the new query API key. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client QueryKeysClient) Create(ctx context.Context, resourceGroupName string, searchServiceName string, name string, clientRequestID *uuid.UUID) (result QueryKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryKeysClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceGroupName, searchServiceName, name, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client QueryKeysClient) CreatePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, name string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/createQueryKey/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client QueryKeysClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client QueryKeysClient) CreateResponder(resp *http.Response) (result QueryKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified query key. Unlike admin keys, query keys are not regenerated. The process for +// regenerating a query key is to delete and then recreate it. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// key - the query key to be deleted. Query keys are identified by value, not by name. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client QueryKeysClient) Delete(ctx context.Context, resourceGroupName string, searchServiceName string, key string, clientRequestID *uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryKeysClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, searchServiceName, key, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client QueryKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, key string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "key": autorest.Encode("path", key), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/deleteQueryKey/{key}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client QueryKeysClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client QueryKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListBySearchService returns the list of query API keys for the given Azure Cognitive Search service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client QueryKeysClient) ListBySearchService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result ListQueryKeysResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryKeysClient.ListBySearchService") + defer func() { + sc := -1 + if result.lqkr.Response.Response != nil { + sc = result.lqkr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySearchServiceNextResults + req, err := client.ListBySearchServicePreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "ListBySearchService", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySearchServiceSender(req) + if err != nil { + result.lqkr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "ListBySearchService", resp, "Failure sending request") + return + } + + result.lqkr, err = client.ListBySearchServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "ListBySearchService", resp, "Failure responding to request") + } + if result.lqkr.hasNextLink() && result.lqkr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySearchServicePreparer prepares the ListBySearchService request. +func (client QueryKeysClient) ListBySearchServicePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySearchServiceSender sends the ListBySearchService request. The method will close the +// http.Response Body if it receives an error. +func (client QueryKeysClient) ListBySearchServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySearchServiceResponder handles the response to the ListBySearchService request. The method always +// closes the http.Response Body. +func (client QueryKeysClient) ListBySearchServiceResponder(resp *http.Response) (result ListQueryKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySearchServiceNextResults retrieves the next set of results, if any. +func (client QueryKeysClient) listBySearchServiceNextResults(ctx context.Context, lastResults ListQueryKeysResult) (result ListQueryKeysResult, err error) { + req, err := lastResults.listQueryKeysResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "search.QueryKeysClient", "listBySearchServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySearchServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "search.QueryKeysClient", "listBySearchServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySearchServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "listBySearchServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySearchServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client QueryKeysClient) ListBySearchServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result ListQueryKeysResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryKeysClient.ListBySearchService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySearchService(ctx, resourceGroupName, searchServiceName, clientRequestID) + return +} diff --git a/services/search/mgmt/2020-08-01/search/searchapi/interfaces.go b/services/search/mgmt/2020-08-01/search/searchapi/interfaces.go new file mode 100644 index 000000000000..bfe799d980eb --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/searchapi/interfaces.go @@ -0,0 +1,94 @@ +package searchapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2020-08-01/search" + "github.com/Azure/go-autorest/autorest" + "github.com/satori/go.uuid" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result search.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*search.OperationsClient)(nil) + +// AdminKeysClientAPI contains the set of methods on the AdminKeysClient type. +type AdminKeysClientAPI interface { + Get(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.AdminKeyResult, err error) + Regenerate(ctx context.Context, resourceGroupName string, searchServiceName string, keyKind search.AdminKeyKind, clientRequestID *uuid.UUID) (result search.AdminKeyResult, err error) +} + +var _ AdminKeysClientAPI = (*search.AdminKeysClient)(nil) + +// QueryKeysClientAPI contains the set of methods on the QueryKeysClient type. +type QueryKeysClientAPI interface { + Create(ctx context.Context, resourceGroupName string, searchServiceName string, name string, clientRequestID *uuid.UUID) (result search.QueryKey, err error) + Delete(ctx context.Context, resourceGroupName string, searchServiceName string, key string, clientRequestID *uuid.UUID) (result autorest.Response, err error) + ListBySearchService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.ListQueryKeysResultPage, err error) + ListBySearchServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.ListQueryKeysResultIterator, err error) +} + +var _ QueryKeysClientAPI = (*search.QueryKeysClient)(nil) + +// ServicesClientAPI contains the set of methods on the ServicesClient type. +type ServicesClientAPI interface { + CheckNameAvailability(ctx context.Context, checkNameAvailabilityInput search.CheckNameAvailabilityInput, clientRequestID *uuid.UUID) (result search.CheckNameAvailabilityOutput, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, searchServiceName string, service search.Service, clientRequestID *uuid.UUID) (result search.ServicesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.Service, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, clientRequestID *uuid.UUID) (result search.ServiceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, clientRequestID *uuid.UUID) (result search.ServiceListResultIterator, err error) + ListBySubscription(ctx context.Context, clientRequestID *uuid.UUID) (result search.ServiceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context, clientRequestID *uuid.UUID) (result search.ServiceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, searchServiceName string, service search.ServiceUpdate, clientRequestID *uuid.UUID) (result search.Service, err error) +} + +var _ ServicesClientAPI = (*search.ServicesClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + ListSupported(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.PrivateLinkResourcesResult, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*search.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (result search.PrivateEndpointConnection, err error) + Get(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, clientRequestID *uuid.UUID) (result search.PrivateEndpointConnection, err error) + ListByService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.PrivateEndpointConnectionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.PrivateEndpointConnectionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string, privateEndpointConnection search.PrivateEndpointConnection, clientRequestID *uuid.UUID) (result search.PrivateEndpointConnection, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*search.PrivateEndpointConnectionsClient)(nil) + +// SharedPrivateLinkResourcesClientAPI contains the set of methods on the SharedPrivateLinkResourcesClient type. +type SharedPrivateLinkResourcesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, sharedPrivateLinkResource search.SharedPrivateLinkResource, clientRequestID *uuid.UUID) (result search.SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (result search.SharedPrivateLinkResourcesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (result search.SharedPrivateLinkResource, err error) + ListByService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.SharedPrivateLinkResourceListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result search.SharedPrivateLinkResourceListResultIterator, err error) +} + +var _ SharedPrivateLinkResourcesClientAPI = (*search.SharedPrivateLinkResourcesClient)(nil) diff --git a/services/search/mgmt/2020-08-01/search/services.go b/services/search/mgmt/2020-08-01/search/services.go new file mode 100644 index 000000000000..d6725c3d34c5 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/services.go @@ -0,0 +1,726 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// ServicesClient is the client that can be used to manage Azure Cognitive Search services and API keys. +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability checks whether or not the given search service name is available for use. Search service names +// must be globally unique since they are part of the service URI (https://.search.windows.net). +// Parameters: +// checkNameAvailabilityInput - the resource name and type to check. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityInput CheckNameAvailabilityInput, clientRequestID *uuid.UUID) (result CheckNameAvailabilityOutput, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: checkNameAvailabilityInput, + Constraints: []validation.Constraint{{Target: "checkNameAvailabilityInput.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "checkNameAvailabilityInput.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("search.ServicesClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityInput, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityInput CheckNameAvailabilityInput, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Search/checkNameAvailability", pathParameters), + autorest.WithJSON(checkNameAvailabilityInput), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityOutput, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a search service in the given resource group. If the search service already +// exists, all properties will be updated with the given values. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service to create or update. 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. Search +// service names must be globally unique since they are part of the service URI +// (https://.search.windows.net). You cannot change the service name after the service is created. +// service - the definition of the search service to create or update. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, searchServiceName string, service Service, clientRequestID *uuid.UUID) (result ServicesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: service, + Constraints: []validation.Constraint{{Target: "service.ServiceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "service.ServiceProperties.ReplicaCount", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "service.ServiceProperties.ReplicaCount", Name: validation.InclusiveMaximum, Rule: int64(12), Chain: nil}, + {Target: "service.ServiceProperties.ReplicaCount", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + {Target: "service.ServiceProperties.PartitionCount", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "service.ServiceProperties.PartitionCount", Name: validation.InclusiveMaximum, Rule: int64(12), Chain: nil}, + {Target: "service.ServiceProperties.PartitionCount", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("search.ServicesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, searchServiceName, service, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, service Service, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}", pathParameters), + autorest.WithJSON(service), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (future ServicesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a search service in the given resource group, along with its associated resources. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the search service with the given name in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets a list of all search services in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, clientRequestID *uuid.UUID) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "search.ServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "search.ServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, clientRequestID *uuid.UUID) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, clientRequestID) + return +} + +// ListBySubscription gets a list of all search services in the given subscription. +// Parameters: +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) ListBySubscription(ctx context.Context, clientRequestID *uuid.UUID) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.slr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Search/searchServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ServicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "search.ServicesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "search.ServicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListBySubscriptionComplete(ctx context.Context, clientRequestID *uuid.UUID) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx, clientRequestID) + return +} + +// Update updates an existing search service in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service to update. +// service - the definition of the search service to update. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, searchServiceName string, service ServiceUpdate, clientRequestID *uuid.UUID) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, searchServiceName, service, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.ServicesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, service ServiceUpdate, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}", pathParameters), + autorest.WithJSON(service), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/search/mgmt/2020-08-01/search/sharedprivatelinkresources.go b/services/search/mgmt/2020-08-01/search/sharedprivatelinkresources.go new file mode 100644 index 000000000000..b46fe87cd0a7 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/sharedprivatelinkresources.go @@ -0,0 +1,430 @@ +package search + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// SharedPrivateLinkResourcesClient is the client that can be used to manage Azure Cognitive Search services and API +// keys. +type SharedPrivateLinkResourcesClient struct { + BaseClient +} + +// NewSharedPrivateLinkResourcesClient creates an instance of the SharedPrivateLinkResourcesClient client. +func NewSharedPrivateLinkResourcesClient(subscriptionID string) SharedPrivateLinkResourcesClient { + return NewSharedPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSharedPrivateLinkResourcesClientWithBaseURI creates an instance of the SharedPrivateLinkResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewSharedPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) SharedPrivateLinkResourcesClient { + return SharedPrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate initiates the creation or update of a shared private link resource managed by the search service in +// the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// sharedPrivateLinkResourceName - the name of the shared private link resource managed by the Azure Cognitive +// Search service within the specified resource group. +// sharedPrivateLinkResource - the definition of the shared private link resource to create or update. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, sharedPrivateLinkResource SharedPrivateLinkResource, clientRequestID *uuid.UUID) (result SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, searchServiceName, sharedPrivateLinkResourceName, sharedPrivateLinkResource, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, sharedPrivateLinkResource SharedPrivateLinkResource, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithJSON(sharedPrivateLinkResource), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateSender(req *http.Request) (future SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete initiates the deletion of the shared private link resource from the search service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// sharedPrivateLinkResourceName - the name of the shared private link resource managed by the Azure Cognitive +// Search service within the specified resource group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client SharedPrivateLinkResourcesClient) Delete(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (result SharedPrivateLinkResourcesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, searchServiceName, sharedPrivateLinkResourceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SharedPrivateLinkResourcesClient) DeletePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) DeleteSender(req *http.Request) (future SharedPrivateLinkResourcesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the shared private link resource managed by the search service in the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// sharedPrivateLinkResourceName - the name of the shared private link resource managed by the Azure Cognitive +// Search service within the specified resource group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client SharedPrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (result SharedPrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, searchServiceName, sharedPrivateLinkResourceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SharedPrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) GetResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets a list of all shared private link resources managed by the given service. +// Parameters: +// resourceGroupName - the name of the resource group within the current subscription. You can obtain this +// value from the Azure Resource Manager API or the portal. +// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource +// group. +// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be +// included in response information as a way to track the request. +func (client SharedPrivateLinkResourcesClient) ListByService(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result SharedPrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.ListByService") + defer func() { + sc := -1 + if result.splrlr.Response.Response != nil { + sc = result.splrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.splrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "ListByService", resp, "Failure sending request") + return + } + + result.splrlr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "ListByService", resp, "Failure responding to request") + } + if result.splrlr.hasNextLink() && result.splrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client SharedPrivateLinkResourcesClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "searchServiceName": autorest.Encode("path", searchServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if clientRequestID != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) ListByServiceResponder(resp *http.Response) (result SharedPrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client SharedPrivateLinkResourcesClient) listByServiceNextResults(ctx context.Context, lastResults SharedPrivateLinkResourceListResult) (result SharedPrivateLinkResourceListResult, err error) { + req, err := lastResults.sharedPrivateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "search.SharedPrivateLinkResourcesClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client SharedPrivateLinkResourcesClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result SharedPrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, searchServiceName, clientRequestID) + return +} diff --git a/services/search/mgmt/2020-08-01/search/version.go b/services/search/mgmt/2020-08-01/search/version.go new file mode 100644 index 000000000000..64a72f7f2861 --- /dev/null +++ b/services/search/mgmt/2020-08-01/search/version.go @@ -0,0 +1,30 @@ +package search + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " search/2020-08-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}