vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2018-01-16 13:20:59 +00:00
parent 8e83fb6fb9
commit 7d3a17725d
4878 changed files with 1974213 additions and 201199 deletions
@@ -0,0 +1,49 @@
// Package search implements the Azure ARM Search service API version 2016-09-01.
//
// Search Client
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 = ""
)
// BaseClient is the base client for Search.
type BaseClient struct {
autorest.Client
BaseURI string
}
// New creates an instance of the BaseClient client.
func New() BaseClient {
return NewWithBaseURI(DefaultBaseURI)
}
// NewWithBaseURI creates an instance of the BaseClient client.
func NewWithBaseURI(baseURI string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
}
}
@@ -0,0 +1,424 @@
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/satori/go.uuid"
"net/http"
)
// DataSourcesClient is the search Client
type DataSourcesClient struct {
BaseClient
}
// NewDataSourcesClient creates an instance of the DataSourcesClient client.
func NewDataSourcesClient() DataSourcesClient {
return NewDataSourcesClientWithBaseURI(DefaultBaseURI)
}
// NewDataSourcesClientWithBaseURI creates an instance of the DataSourcesClient client.
func NewDataSourcesClientWithBaseURI(baseURI string) DataSourcesClient {
return DataSourcesClient{NewWithBaseURI(baseURI)}
}
// Create creates a new Azure Search datasource.
//
// dataSource is the definition of the datasource to create. clientRequestID is the tracking ID sent with the request
// to help with debugging.
func (client DataSourcesClient) Create(ctx context.Context, dataSource DataSource, clientRequestID *uuid.UUID) (result DataSource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: dataSource,
Constraints: []validation.Constraint{{Target: "dataSource.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "dataSource.Type", Name: validation.Null, Rule: true, Chain: nil},
{Target: "dataSource.Credentials", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "dataSource.Credentials.ConnectionString", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "dataSource.Container", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "dataSource.Container.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.DataSourcesClient", "Create")
}
req, err := client.CreatePreparer(ctx, dataSource, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "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.DataSourcesClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client DataSourcesClient) CreatePreparer(ctx context.Context, dataSource DataSource, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/datasources"),
autorest.WithJSON(dataSource),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 DataSourcesClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client DataSourcesClient) CreateResponder(resp *http.Response) (result DataSource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateOrUpdate creates a new Azure Search datasource or updates a datasource if it already exists.
//
// dataSourceName is the name of the datasource to create or update. dataSource is the definition of the datasource to
// create or update. clientRequestID is the tracking ID sent with the request to help with debugging. ifMatch is
// defines the If-Match condition. The operation will be performed only if the ETag on the server matches this value.
// ifNoneMatch is defines the If-None-Match condition. The operation will be performed only if the ETag on the server
// does not match this value.
func (client DataSourcesClient) CreateOrUpdate(ctx context.Context, dataSourceName string, dataSource DataSource, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result DataSource, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: dataSource,
Constraints: []validation.Constraint{{Target: "dataSource.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "dataSource.Type", Name: validation.Null, Rule: true, Chain: nil},
{Target: "dataSource.Credentials", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "dataSource.Credentials.ConnectionString", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "dataSource.Container", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "dataSource.Container.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.DataSourcesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(ctx, dataSourceName, dataSource, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client DataSourcesClient) CreateOrUpdatePreparer(ctx context.Context, dataSourceName string, dataSource DataSource, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"dataSourceName": autorest.Encode("path", dataSourceName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/datasources('{dataSourceName}')", pathParameters),
autorest.WithJSON(dataSource),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 DataSourcesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client DataSourcesClient) CreateOrUpdateResponder(resp *http.Response) (result DataSource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an Azure Search datasource.
//
// dataSourceName is the name of the datasource to delete. clientRequestID is the tracking ID sent with the request to
// help with debugging. ifMatch is defines the If-Match condition. The operation will be performed only if the ETag on
// the server matches this value. ifNoneMatch is defines the If-None-Match condition. The operation will be performed
// only if the ETag on the server does not match this value.
func (client DataSourcesClient) Delete(ctx context.Context, dataSourceName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, dataSourceName, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client DataSourcesClient) DeletePreparer(ctx context.Context, dataSourceName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"dataSourceName": autorest.Encode("path", dataSourceName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/datasources('{dataSourceName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 DataSourcesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client DataSourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
autorest.ByClosing())
result.Response = resp
return
}
// Get retrieves a datasource definition from Azure Search.
//
// dataSourceName is the name of the datasource to retrieve. clientRequestID is the tracking ID sent with the request
// to help with debugging.
func (client DataSourcesClient) Get(ctx context.Context, dataSourceName string, clientRequestID *uuid.UUID) (result DataSource, err error) {
req, err := client.GetPreparer(ctx, dataSourceName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "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.DataSourcesClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client DataSourcesClient) GetPreparer(ctx context.Context, dataSourceName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"dataSourceName": autorest.Encode("path", dataSourceName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/datasources('{dataSourceName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 DataSourcesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client DataSourcesClient) GetResponder(resp *http.Response) (result DataSource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List lists all datasources available for an Azure Search service.
//
// clientRequestID is the tracking ID sent with the request to help with debugging.
func (client DataSourcesClient) List(ctx context.Context, clientRequestID *uuid.UUID) (result DataSourceListResult, err error) {
req, err := client.ListPreparer(ctx, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "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.DataSourcesClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DataSourcesClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client DataSourcesClient) ListPreparer(ctx context.Context, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/datasources"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
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 DataSourcesClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, 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 DataSourcesClient) ListResponder(resp *http.Response) (result DataSourceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,105 @@
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/satori/go.uuid"
"net/http"
)
// DocumentsProxyClient is the search Client
type DocumentsProxyClient struct {
BaseClient
}
// NewDocumentsProxyClient creates an instance of the DocumentsProxyClient client.
func NewDocumentsProxyClient() DocumentsProxyClient {
return NewDocumentsProxyClientWithBaseURI(DefaultBaseURI)
}
// NewDocumentsProxyClientWithBaseURI creates an instance of the DocumentsProxyClient client.
func NewDocumentsProxyClientWithBaseURI(baseURI string) DocumentsProxyClient {
return DocumentsProxyClient{NewWithBaseURI(baseURI)}
}
// Count queries the number of documents in the Azure Search index.
//
// clientRequestID is the tracking ID sent with the request to help with debugging.
func (client DocumentsProxyClient) Count(ctx context.Context, clientRequestID *uuid.UUID) (result Int64, err error) {
req, err := client.CountPreparer(ctx, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DocumentsProxyClient", "Count", nil, "Failure preparing request")
return
}
resp, err := client.CountSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.DocumentsProxyClient", "Count", resp, "Failure sending request")
return
}
result, err = client.CountResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.DocumentsProxyClient", "Count", resp, "Failure responding to request")
}
return
}
// CountPreparer prepares the Count request.
func (client DocumentsProxyClient) CountPreparer(ctx context.Context, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/docs/$count"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CountSender sends the Count request. The method will close the
// http.Response Body if it receives an error.
func (client DocumentsProxyClient) CountSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CountResponder handles the response to the Count request. The method always
// closes the http.Response Body.
func (client DocumentsProxyClient) CountResponder(resp *http.Response) (result Int64, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result.Value),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,627 @@
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/satori/go.uuid"
"net/http"
)
// IndexersClient is the search Client
type IndexersClient struct {
BaseClient
}
// NewIndexersClient creates an instance of the IndexersClient client.
func NewIndexersClient() IndexersClient {
return NewIndexersClientWithBaseURI(DefaultBaseURI)
}
// NewIndexersClientWithBaseURI creates an instance of the IndexersClient client.
func NewIndexersClientWithBaseURI(baseURI string) IndexersClient {
return IndexersClient{NewWithBaseURI(baseURI)}
}
// Create creates a new Azure Search indexer.
//
// indexer is the definition of the indexer to create. clientRequestID is the tracking ID sent with the request to help
// with debugging.
func (client IndexersClient) Create(ctx context.Context, indexer Indexer, clientRequestID *uuid.UUID) (result Indexer, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: indexer,
Constraints: []validation.Constraint{{Target: "indexer.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.DataSourceName", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.TargetIndexName", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.Schedule", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "indexer.Schedule.Interval", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.IndexersClient", "Create")
}
req, err := client.CreatePreparer(ctx, indexer, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "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.IndexersClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client IndexersClient) CreatePreparer(ctx context.Context, indexer Indexer, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/indexers"),
autorest.WithJSON(indexer),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 IndexersClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client IndexersClient) CreateResponder(resp *http.Response) (result Indexer, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateOrUpdate creates a new Azure Search indexer or updates an indexer if it already exists.
//
// indexerName is the name of the indexer to create or update. indexer is the definition of the indexer to create or
// update. clientRequestID is the tracking ID sent with the request to help with debugging. ifMatch is defines the
// If-Match condition. The operation will be performed only if the ETag on the server matches this value. ifNoneMatch
// is defines the If-None-Match condition. The operation will be performed only if the ETag on the server does not
// match this value.
func (client IndexersClient) CreateOrUpdate(ctx context.Context, indexerName string, indexer Indexer, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result Indexer, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: indexer,
Constraints: []validation.Constraint{{Target: "indexer.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.DataSourceName", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.TargetIndexName", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexer.Schedule", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "indexer.Schedule.Interval", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.IndexersClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(ctx, indexerName, indexer, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.IndexersClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client IndexersClient) CreateOrUpdatePreparer(ctx context.Context, indexerName string, indexer Indexer, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')", pathParameters),
autorest.WithJSON(indexer),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 IndexersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client IndexersClient) CreateOrUpdateResponder(resp *http.Response) (result Indexer, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an Azure Search indexer.
//
// indexerName is the name of the indexer to delete. clientRequestID is the tracking ID sent with the request to help
// with debugging. ifMatch is defines the If-Match condition. The operation will be performed only if the ETag on the
// server matches this value. ifNoneMatch is defines the If-None-Match condition. The operation will be performed only
// if the ETag on the server does not match this value.
func (client IndexersClient) Delete(ctx context.Context, indexerName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, indexerName, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client IndexersClient) DeletePreparer(ctx context.Context, indexerName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 IndexersClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client IndexersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
autorest.ByClosing())
result.Response = resp
return
}
// Get retrieves an indexer definition from Azure Search.
//
// indexerName is the name of the indexer to retrieve. clientRequestID is the tracking ID sent with the request to help
// with debugging.
func (client IndexersClient) Get(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (result Indexer, err error) {
req, err := client.GetPreparer(ctx, indexerName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "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.IndexersClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client IndexersClient) GetPreparer(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 IndexersClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client IndexersClient) GetResponder(resp *http.Response) (result Indexer, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetStatus returns the current status and execution history of an indexer.
//
// indexerName is the name of the indexer for which to retrieve status. clientRequestID is the tracking ID sent with
// the request to help with debugging.
func (client IndexersClient) GetStatus(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (result IndexerExecutionInfo, err error) {
req, err := client.GetStatusPreparer(ctx, indexerName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "GetStatus", nil, "Failure preparing request")
return
}
resp, err := client.GetStatusSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.IndexersClient", "GetStatus", resp, "Failure sending request")
return
}
result, err = client.GetStatusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "GetStatus", resp, "Failure responding to request")
}
return
}
// GetStatusPreparer prepares the GetStatus request.
func (client IndexersClient) GetStatusPreparer(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')/search.status", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetStatusSender sends the GetStatus request. The method will close the
// http.Response Body if it receives an error.
func (client IndexersClient) GetStatusSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetStatusResponder handles the response to the GetStatus request. The method always
// closes the http.Response Body.
func (client IndexersClient) GetStatusResponder(resp *http.Response) (result IndexerExecutionInfo, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List lists all indexers available for an Azure Search service.
//
// clientRequestID is the tracking ID sent with the request to help with debugging.
func (client IndexersClient) List(ctx context.Context, clientRequestID *uuid.UUID) (result IndexerListResult, err error) {
req, err := client.ListPreparer(ctx, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "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.IndexersClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client IndexersClient) ListPreparer(ctx context.Context, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/indexers"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
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 IndexersClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, 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 IndexersClient) ListResponder(resp *http.Response) (result IndexerListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Reset resets the change tracking state associated with an Azure Search indexer.
//
// indexerName is the name of the indexer to reset. clientRequestID is the tracking ID sent with the request to help
// with debugging.
func (client IndexersClient) Reset(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (result autorest.Response, err error) {
req, err := client.ResetPreparer(ctx, indexerName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Reset", nil, "Failure preparing request")
return
}
resp, err := client.ResetSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Reset", resp, "Failure sending request")
return
}
result, err = client.ResetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Reset", resp, "Failure responding to request")
}
return
}
// ResetPreparer prepares the Reset request.
func (client IndexersClient) ResetPreparer(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')/search.reset", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ResetSender sends the Reset request. The method will close the
// http.Response Body if it receives an error.
func (client IndexersClient) ResetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// ResetResponder handles the response to the Reset request. The method always
// closes the http.Response Body.
func (client IndexersClient) ResetResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Run runs an Azure Search indexer on-demand.
//
// indexerName is the name of the indexer to run. clientRequestID is the tracking ID sent with the request to help with
// debugging.
func (client IndexersClient) Run(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (result autorest.Response, err error) {
req, err := client.RunPreparer(ctx, indexerName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Run", nil, "Failure preparing request")
return
}
resp, err := client.RunSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Run", resp, "Failure sending request")
return
}
result, err = client.RunResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexersClient", "Run", resp, "Failure responding to request")
}
return
}
// RunPreparer prepares the Run request.
func (client IndexersClient) RunPreparer(ctx context.Context, indexerName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexerName": autorest.Encode("path", indexerName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexers('{indexerName}')/search.run", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// RunSender sends the Run request. The method will close the
// http.Response Body if it receives an error.
func (client IndexersClient) RunSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// RunResponder handles the response to the Run request. The method always
// closes the http.Response Body.
func (client IndexersClient) RunResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
@@ -0,0 +1,577 @@
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/satori/go.uuid"
"net/http"
)
// IndexesClient is the search Client
type IndexesClient struct {
BaseClient
}
// NewIndexesClient creates an instance of the IndexesClient client.
func NewIndexesClient() IndexesClient {
return NewIndexesClientWithBaseURI(DefaultBaseURI)
}
// NewIndexesClientWithBaseURI creates an instance of the IndexesClient client.
func NewIndexesClientWithBaseURI(baseURI string) IndexesClient {
return IndexesClient{NewWithBaseURI(baseURI)}
}
// Analyze shows how an analyzer breaks text into tokens.
//
// indexName is the name of the index for which to test an analyzer. request is the text and analyzer or analysis
// components to test. clientRequestID is the tracking ID sent with the request to help with debugging.
func (client IndexesClient) Analyze(ctx context.Context, indexName string, request AnalyzeRequest, clientRequestID *uuid.UUID) (result AnalyzeResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: request,
Constraints: []validation.Constraint{{Target: "request.Text", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.IndexesClient", "Analyze")
}
req, err := client.AnalyzePreparer(ctx, indexName, request, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Analyze", nil, "Failure preparing request")
return
}
resp, err := client.AnalyzeSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Analyze", resp, "Failure sending request")
return
}
result, err = client.AnalyzeResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Analyze", resp, "Failure responding to request")
}
return
}
// AnalyzePreparer prepares the Analyze request.
func (client IndexesClient) AnalyzePreparer(ctx context.Context, indexName string, request AnalyzeRequest, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexName": autorest.Encode("path", indexName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexes('{indexName}')/search.analyze", pathParameters),
autorest.WithJSON(request),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// AnalyzeSender sends the Analyze request. The method will close the
// http.Response Body if it receives an error.
func (client IndexesClient) AnalyzeSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// AnalyzeResponder handles the response to the Analyze request. The method always
// closes the http.Response Body.
func (client IndexesClient) AnalyzeResponder(resp *http.Response) (result AnalyzeResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Create creates a new Azure Search index.
//
// indexParameter is the definition of the index to create. clientRequestID is the tracking ID sent with the request to
// help with debugging.
func (client IndexesClient) Create(ctx context.Context, indexParameter Index, clientRequestID *uuid.UUID) (result Index, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: indexParameter,
Constraints: []validation.Constraint{{Target: "indexParameter.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexParameter.Fields", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexParameter.CorsOptions", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "indexParameter.CorsOptions.AllowedOrigins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.IndexesClient", "Create")
}
req, err := client.CreatePreparer(ctx, indexParameter, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "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.IndexesClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client IndexesClient) CreatePreparer(ctx context.Context, indexParameter Index, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/indexes"),
autorest.WithJSON(indexParameter),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 IndexesClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client IndexesClient) CreateResponder(resp *http.Response) (result Index, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateOrUpdate creates a new Azure Search index or updates an index if it already exists.
//
// indexName is the definition of the index to create or update. indexParameter is the definition of the index to
// create or update. allowIndexDowntime is allows new analyzers, tokenizers, token filters, or char filters to be added
// to an index by taking the index offline for at least a few seconds. This temporarily causes indexing and query
// requests to fail. Performance and write availability of the index can be impaired for several minutes after the
// index is updated, or longer for very large indexes. clientRequestID is the tracking ID sent with the request to help
// with debugging. ifMatch is defines the If-Match condition. The operation will be performed only if the ETag on the
// server matches this value. ifNoneMatch is defines the If-None-Match condition. The operation will be performed only
// if the ETag on the server does not match this value.
func (client IndexesClient) CreateOrUpdate(ctx context.Context, indexName string, indexParameter Index, allowIndexDowntime *bool, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result Index, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: indexParameter,
Constraints: []validation.Constraint{{Target: "indexParameter.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexParameter.Fields", Name: validation.Null, Rule: true, Chain: nil},
{Target: "indexParameter.CorsOptions", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "indexParameter.CorsOptions.AllowedOrigins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.IndexesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(ctx, indexName, indexParameter, allowIndexDowntime, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.IndexesClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client IndexesClient) CreateOrUpdatePreparer(ctx context.Context, indexName string, indexParameter Index, allowIndexDowntime *bool, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexName": autorest.Encode("path", indexName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if allowIndexDowntime != nil {
queryParameters["allowIndexDowntime"] = autorest.Encode("query", *allowIndexDowntime)
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexes('{indexName}')", pathParameters),
autorest.WithJSON(indexParameter),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 IndexesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client IndexesClient) CreateOrUpdateResponder(resp *http.Response) (result Index, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes an Azure Search index and all the documents it contains.
//
// indexName is the name of the index to delete. clientRequestID is the tracking ID sent with the request to help with
// debugging. ifMatch is defines the If-Match condition. The operation will be performed only if the ETag on the server
// matches this value. ifNoneMatch is defines the If-None-Match condition. The operation will be performed only if the
// ETag on the server does not match this value.
func (client IndexesClient) Delete(ctx context.Context, indexName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, indexName, clientRequestID, ifMatch, ifNoneMatch)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client IndexesClient) DeletePreparer(ctx context.Context, indexName string, clientRequestID *uuid.UUID, ifMatch string, ifNoneMatch string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexName": autorest.Encode("path", indexName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexes('{indexName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
if len(ifMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
}
if len(ifNoneMatch) > 0 {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
}
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 IndexesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client IndexesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
autorest.ByClosing())
result.Response = resp
return
}
// Get retrieves an index definition from Azure Search.
//
// indexName is the name of the index to retrieve. clientRequestID is the tracking ID sent with the request to help
// with debugging.
func (client IndexesClient) Get(ctx context.Context, indexName string, clientRequestID *uuid.UUID) (result Index, err error) {
req, err := client.GetPreparer(ctx, indexName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "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.IndexesClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client IndexesClient) GetPreparer(ctx context.Context, indexName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexName": autorest.Encode("path", indexName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexes('{indexName}')", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("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 IndexesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client IndexesClient) GetResponder(resp *http.Response) (result Index, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetStatistics returns statistics for the given index, including a document count and storage usage.
//
// indexName is the name of the index for which to retrieve statistics. clientRequestID is the tracking ID sent with
// the request to help with debugging.
func (client IndexesClient) GetStatistics(ctx context.Context, indexName string, clientRequestID *uuid.UUID) (result IndexGetStatisticsResult, err error) {
req, err := client.GetStatisticsPreparer(ctx, indexName, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "GetStatistics", nil, "Failure preparing request")
return
}
resp, err := client.GetStatisticsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.IndexesClient", "GetStatistics", resp, "Failure sending request")
return
}
result, err = client.GetStatisticsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "GetStatistics", resp, "Failure responding to request")
}
return
}
// GetStatisticsPreparer prepares the GetStatistics request.
func (client IndexesClient) GetStatisticsPreparer(ctx context.Context, indexName string, clientRequestID *uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"indexName": autorest.Encode("path", indexName),
}
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/indexes('{indexName}')/search.stats", pathParameters),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetStatisticsSender sends the GetStatistics request. The method will close the
// http.Response Body if it receives an error.
func (client IndexesClient) GetStatisticsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// GetStatisticsResponder handles the response to the GetStatistics request. The method always
// closes the http.Response Body.
func (client IndexesClient) GetStatisticsResponder(resp *http.Response) (result IndexGetStatisticsResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List lists all indexes available for an Azure Search service.
//
// selectParameter is selects which properties of the index definitions to retrieve. Specified as a comma-separated
// list of JSON property names, or '*' for all properties. The default is all properties. clientRequestID is the
// tracking ID sent with the request to help with debugging.
func (client IndexesClient) List(ctx context.Context, selectParameter string, clientRequestID *uuid.UUID) (result IndexListResult, err error) {
req, err := client.ListPreparer(ctx, selectParameter, clientRequestID)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "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.IndexesClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.IndexesClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client IndexesClient) ListPreparer(ctx context.Context, selectParameter string, clientRequestID *uuid.UUID) (*http.Request, error) {
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(selectParameter) > 0 {
queryParameters["$select"] = autorest.Encode("query", selectParameter)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/indexes"),
autorest.WithQueryParameters(queryParameters))
if clientRequestID != nil {
preparer = autorest.DecoratePreparer(preparer,
autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
}
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 IndexesClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, 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 IndexesClient) ListResponder(resp *http.Response) (result IndexListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}
@@ -0,0 +1,107 @@
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"
"net/http"
)
// AdminKeysClient is the client that can be used to manage Azure 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.
func NewAdminKeysClientWithBaseURI(baseURI string, subscriptionID string) AdminKeysClient {
return AdminKeysClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List returns the primary and secondary API keys for the given Azure Search service.
//
// resourceGroupName is the name of the resource group within the current subscription. serviceName is the name of the
// Search service for which to list admin keys.
func (client AdminKeysClient) List(ctx context.Context, resourceGroupName string, serviceName string) (result AdminKeyResult, err error) {
req, err := client.ListPreparer(ctx, resourceGroupName, serviceName)
if err != nil {
err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "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.AdminKeysClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.AdminKeysClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client AdminKeysClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serviceName": autorest.Encode("path", serviceName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-02-28"
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/{serviceName}/listAdminKeys", pathParameters),
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 AdminKeysClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client AdminKeysClient) ListResponder(resp *http.Response) (result AdminKeyResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,51 @@
// Package search implements the Azure ARM Search service API version 2015-02-28.
//
// Client that can be used to manage Azure 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.
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
@@ -0,0 +1,172 @@
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"
)
// ProvisioningState enumerates the values for provisioning state.
type ProvisioningState string
const (
// Failed ...
Failed ProvisioningState = "failed"
// Provisioning ...
Provisioning ProvisioningState = "provisioning"
// Succeeded ...
Succeeded ProvisioningState = "succeeded"
)
// 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"
)
// SkuType enumerates the values for sku type.
type SkuType string
const (
// Free ...
Free SkuType = "free"
// Standard ...
Standard SkuType = "standard"
// Standard2 ...
Standard2 SkuType = "standard2"
)
// AdminKeyResult response containing the primary and secondary API keys for a given Azure Search service.
type AdminKeyResult struct {
autorest.Response `json:"-"`
// PrimaryKey - The primary API key of the Search service.
PrimaryKey *string `json:"primaryKey,omitempty"`
// SecondaryKey - The secondary API key of the Search service.
SecondaryKey *string `json:"secondaryKey,omitempty"`
}
// ListQueryKeysResult response containing the query API keys for a given Azure Search service.
type ListQueryKeysResult struct {
autorest.Response `json:"-"`
// Value - The query keys for the Azure Search service.
Value *[]QueryKey `json:"value,omitempty"`
}
// QueryKey describes an API key for a given Azure Search service that has permissions for query operations only.
type QueryKey struct {
// Name - The name of the query API key; may be empty.
Name *string `json:"name,omitempty"`
// Key - The value of the query API key.
Key *string `json:"key,omitempty"`
}
// Resource ...
type Resource struct {
// ID - Resource Id
ID *string `json:"id,omitempty"`
// Name - Resource name
Name *string `json:"name,omitempty"`
// Type - Resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags *map[string]*string `json:"tags,omitempty"`
}
// ServiceCreateOrUpdateParameters properties that describe an Azure Search service.
type ServiceCreateOrUpdateParameters struct {
// Location - The geographic location of the Search service.
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the Search service in the Azure Portal.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the Search service.
Properties *ServiceProperties `json:"properties,omitempty"`
}
// ServiceListResult response containing a list of Azure Search services for a given resource group.
type ServiceListResult struct {
autorest.Response `json:"-"`
// Value - The Search services in the resource group.
Value *[]ServiceResource `json:"value,omitempty"`
}
// ServiceProperties defines properties of an Azure Search service that can be modified.
type ServiceProperties struct {
// Sku - The SKU of the Search Service, which determines price tier and capacity limits.
Sku *Sku `json:"sku,omitempty"`
// ReplicaCount - The number of replicas in the Search service. If specified, it must be a value between 1 and 6 inclusive.
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.
PartitionCount *int32 `json:"partitionCount,omitempty"`
}
// ServiceReadableProperties defines all the properties of an Azure Search service.
type ServiceReadableProperties struct {
// Status - The status of the Search service. Possible values include: 'ServiceStatusRunning', 'ServiceStatusProvisioning', 'ServiceStatusDeleting', 'ServiceStatusDegraded', 'ServiceStatusDisabled', 'ServiceStatusError'
Status ServiceStatus `json:"status,omitempty"`
// StatusDetails - The details of the Search service status.
StatusDetails *string `json:"statusDetails,omitempty"`
// ProvisioningState - The state of the last provisioning operation performed on the Search service. Possible values include: 'Succeeded', 'Provisioning', 'Failed'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
// Sku - The SKU of the Search Service, which determines price tier and capacity limits.
Sku *Sku `json:"sku,omitempty"`
// ReplicaCount - The number of replicas in the Search service. If specified, it must be a value between 1 and 6 inclusive.
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.
PartitionCount *int32 `json:"partitionCount,omitempty"`
}
// ServiceResource describes an Azure Search service and its current state.
type ServiceResource struct {
autorest.Response `json:"-"`
// ID - The resource Id of the Azure Search service.
ID *string `json:"id,omitempty"`
// Name - The name of the Search service.
Name *string `json:"name,omitempty"`
// Location - The geographic location of the Search service.
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the Search service in the Azure Portal.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the Search service.
Properties *ServiceReadableProperties `json:"properties,omitempty"`
}
// Sku defines the SKU of an Azure Search Service, which determines price tier and capacity limits.
type Sku struct {
// Name - The SKU of the Search service. Possible values include: 'Free', 'Standard', 'Standard2'
Name SkuType `json:"name,omitempty"`
}
// SubResource ...
type SubResource struct {
// ID - Resource Id
ID *string `json:"id,omitempty"`
}
@@ -0,0 +1,107 @@
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"
"net/http"
)
// QueryKeysClient is the client that can be used to manage Azure 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.
func NewQueryKeysClientWithBaseURI(baseURI string, subscriptionID string) QueryKeysClient {
return QueryKeysClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List returns the list of query API keys for the given Azure Search service.
//
// resourceGroupName is the name of the resource group within the current subscription. serviceName is the name of the
// Search service for which to list query keys.
func (client QueryKeysClient) List(ctx context.Context, resourceGroupName string, serviceName string) (result ListQueryKeysResult, err error) {
req, err := client.ListPreparer(ctx, resourceGroupName, serviceName)
if err != nil {
err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "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.QueryKeysClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client QueryKeysClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serviceName": autorest.Encode("path", serviceName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-02-28"
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/{serviceName}/listQueryKeys", pathParameters),
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 QueryKeysClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client QueryKeysClient) ListResponder(resp *http.Response) (result ListQueryKeysResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,241 @@
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"
"net/http"
)
// ServicesClient is the client that can be used to manage Azure 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.
func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient {
return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// 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.
//
// resourceGroupName is the name of the resource group within the current subscription. serviceName is the name of the
// Search service to create or update. parameters is the properties to set or update on the Search service.
func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceCreateOrUpdateParameters) (result ServiceResource, err error) {
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.ServicesClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceCreateOrUpdateParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serviceName": autorest.Encode("path", serviceName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-02-28"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{serviceName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
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) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
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.
//
// resourceGroupName is the name of the resource group within the current subscription. serviceName is the name of the
// Search service to delete.
func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName)
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, serviceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"serviceName": autorest.Encode("path", serviceName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-02-28"
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/{serviceName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
autorest.ByClosing())
result.Response = resp
return
}
// List returns a list of all Search services in the given resource group.
//
// resourceGroupName is the name of the resource group within the current subscription.
func (client ServicesClient) List(ctx context.Context, resourceGroupName string) (result ServiceListResult, err error) {
req, err := client.ListPreparer(ctx, resourceGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesClient", "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.ServicesClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client ServicesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-02-28"
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))
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 ServicesClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}
@@ -0,0 +1,189 @@
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/satori/go.uuid"
"net/http"
)
// AdminKeysClient is the client that can be used to manage Azure 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.
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 Search service.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. keyKind is specifies which key to regenerate. Valid values include 'primary' and
// 'secondary'. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,51 @@
// Package search implements the Azure ARM Search service API version 2015-08-19.
//
// Client that can be used to manage Azure 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.
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
@@ -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 (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"net/http"
)
// AdminKeyKind enumerates the values for admin key kind.
type AdminKeyKind string
const (
// Primary ...
Primary AdminKeyKind = "primary"
// Secondary ...
Secondary AdminKeyKind = "secondary"
)
// HostingMode enumerates the values for hosting mode.
type HostingMode string
const (
// Default ...
Default HostingMode = "default"
// HighDensity ...
HighDensity HostingMode = "highDensity"
)
// ProvisioningState enumerates the values for provisioning state.
type ProvisioningState string
const (
// Failed ...
Failed ProvisioningState = "failed"
// Provisioning ...
Provisioning ProvisioningState = "provisioning"
// Succeeded ...
Succeeded ProvisioningState = "succeeded"
)
// 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"
)
// 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"
)
// UnavailableNameReason enumerates the values for unavailable name reason.
type UnavailableNameReason string
const (
// AlreadyExists ...
AlreadyExists UnavailableNameReason = "AlreadyExists"
// Invalid ...
Invalid UnavailableNameReason = "Invalid"
)
// AdminKeyResult response containing the primary and secondary admin API keys for a given Azure Search service.
type AdminKeyResult struct {
autorest.Response `json:"-"`
// PrimaryKey - The primary admin API key of the Search service.
PrimaryKey *string `json:"primaryKey,omitempty"`
// SecondaryKey - The secondary admin API key of the Search service.
SecondaryKey *string `json:"secondaryKey,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 - A value indicating whether the name is available.
IsNameAvailable *bool `json:"nameAvailable,omitempty"`
// Reason - 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 - 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 *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 programatically 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"`
}
// ListQueryKeysResult response containing the query API keys for a given Azure Search service.
type ListQueryKeysResult struct {
autorest.Response `json:"-"`
// Value - The query keys for the Azure Search service.
Value *[]QueryKey `json:"value,omitempty"`
}
// QueryKey describes an API key for a given Azure Search service that has permissions for query operations only.
type QueryKey struct {
autorest.Response `json:"-"`
// Name - The name of the query API key; may be empty.
Name *string `json:"name,omitempty"`
// Key - The value of the query API key.
Key *string `json:"key,omitempty"`
}
// Resource base type for all Azure resources.
type Resource struct {
// ID - The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
ID *string `json:"id,omitempty"`
// Name - The name of the resource.
Name *string `json:"name,omitempty"`
// Type - The resource type.
Type *string `json:"type,omitempty"`
// Location - The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth).
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the resource in the Azure portal.
Tags *map[string]*string `json:"tags,omitempty"`
}
// Service describes an Azure Search service and its current state.
type Service struct {
autorest.Response `json:"-"`
// ID - The ID of the resource. This can be used with the Azure Resource Manager to link resources together.
ID *string `json:"id,omitempty"`
// Name - The name of the resource.
Name *string `json:"name,omitempty"`
// Type - The resource type.
Type *string `json:"type,omitempty"`
// Location - The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth).
Location *string `json:"location,omitempty"`
// Tags - Tags to help categorize the resource in the Azure portal.
Tags *map[string]*string `json:"tags,omitempty"`
// ServiceProperties - Properties of the Search service.
*ServiceProperties `json:"properties,omitempty"`
// Sku - The SKU of the Search Service, which determines price tier and capacity limits.
Sku *Sku `json:"sku,omitempty"`
}
// 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
}
var v *json.RawMessage
v = m["properties"]
if v != nil {
var properties ServiceProperties
err = json.Unmarshal(*m["properties"], &properties)
if err != nil {
return err
}
s.ServiceProperties = &properties
}
v = m["sku"]
if v != nil {
var sku Sku
err = json.Unmarshal(*m["sku"], &sku)
if err != nil {
return err
}
s.Sku = &sku
}
v = m["id"]
if v != nil {
var ID string
err = json.Unmarshal(*m["id"], &ID)
if err != nil {
return err
}
s.ID = &ID
}
v = m["name"]
if v != nil {
var name string
err = json.Unmarshal(*m["name"], &name)
if err != nil {
return err
}
s.Name = &name
}
v = m["type"]
if v != nil {
var typeVar string
err = json.Unmarshal(*m["type"], &typeVar)
if err != nil {
return err
}
s.Type = &typeVar
}
v = m["location"]
if v != nil {
var location string
err = json.Unmarshal(*m["location"], &location)
if err != nil {
return err
}
s.Location = &location
}
v = m["tags"]
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*m["tags"], &tags)
if err != nil {
return err
}
s.Tags = &tags
}
return nil
}
// ServiceListResult response containing a list of Azure Search services.
type ServiceListResult struct {
autorest.Response `json:"-"`
// Value - The list of Search services.
Value *[]Service `json:"value,omitempty"`
}
// ServiceProperties properties of the Search service.
type ServiceProperties struct {
// ReplicaCount - The number of replicas in the Search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU.
ReplicaCount *int32 `json:"replicaCount,omitempty"`
// PartitionCount - The number of partitions in the Search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3.
PartitionCount *int32 `json:"partitionCount,omitempty"`
// HostingMode - Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: 'Default', 'HighDensity'
HostingMode HostingMode `json:"hostingMode,omitempty"`
// Status - 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 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 - The details of the Search service status.
StatusDetails *string `json:"statusDetails,omitempty"`
// ProvisioningState - 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"`
}
// ServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
type ServicesCreateOrUpdateFuture struct {
azure.Future
req *http.Request
}
// 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.Done(client)
if err != nil {
return
}
if !done {
return s, autorest.NewError("search.ServicesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed")
}
if future.PollingMethod() == azure.PollingLocation {
s, err = client.CreateOrUpdateResponder(future.Response())
return
}
var resp *http.Response
resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req),
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if err != nil {
return
}
s, err = client.CreateOrUpdateResponder(resp)
return
}
// Sku defines the SKU of an Azure 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': Offers maximum capacity per search unit 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'). Possible values include: 'Free', 'Basic', 'Standard', 'Standard2', 'Standard3'
Name SkuName `json:"name,omitempty"`
}
@@ -0,0 +1,264 @@
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/satori/go.uuid"
"net/http"
)
// QueryKeysClient is the client that can be used to manage Azure 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.
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.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. name is the name of the new query API key. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. key is the query key to be deleted. Query keys are identified by value, not by
// name. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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 Search service.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. clientRequestID is 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 ListQueryKeysResult, err error) {
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.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "ListBySearchService", resp, "Failure sending request")
return
}
result, err = client.ListBySearchServiceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.QueryKeysClient", "ListBySearchService", resp, "Failure responding to request")
}
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 = "2015-08-19"
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}/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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,436 @@
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/satori/go.uuid"
"net/http"
)
// ServicesClient is the client that can be used to manage Azure 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.
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://<name>.search.windows.net).
//
// checkNameAvailabilityInput is the resource name and type to check. clientRequestID is 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 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.NewErrorWithValidationError(err, "search.ServicesClient", "CheckNameAvailability")
}
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 = "2015-08-19"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is the name of the Azure 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://<name>.search.windows.net).
// You cannot change the service name after the service is created. service is the definition of the Search service to
// create or update. clientRequestID is 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 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: 12, Chain: nil},
{Target: "service.ServiceProperties.ReplicaCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}},
{Target: "service.ServiceProperties.PartitionCount", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "service.ServiceProperties.PartitionCount", Name: validation.InclusiveMaximum, Rule: 12, Chain: nil},
{Target: "service.ServiceProperties.PartitionCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}},
}},
{Target: "service.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "search.ServicesClient", "CreateOrUpdate")
}
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 = "2015-08-19"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
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) {
sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
future.Future = azure.NewFuture(req)
future.req = req
_, err = future.Done(sender)
if err != nil {
return
}
err = autorest.Respond(future.Response(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated))
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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is the name of the Azure Search service associated
// with the specified resource group. clientRequestID is 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) {
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
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.
//
// resourceGroupName is 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 is 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 ServiceListResult, err error) {
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.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListByResourceGroup", resp, "Failure sending request")
return
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "search.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
}
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 = "2015-08-19"
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 autorest.SendWithSender(client, 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,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}