vendor: update all dependencies to latest versions
This commit is contained in:
Generated
Vendored
+712
@@ -0,0 +1,712 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AccountsClient is the cognitive Services Management Client
|
||||
type AccountsClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewAccountsClient creates an instance of the AccountsClient client.
|
||||
func NewAccountsClient(subscriptionID string) AccountsClient {
|
||||
return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client.
|
||||
func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient {
|
||||
return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// Create create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for
|
||||
// developer to access intelligent APIs. It's also the resource type for billing.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only. parameters is the parameters to provide for
|
||||
// the created account.
|
||||
func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}},
|
||||
{TargetValue: parameters,
|
||||
Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Create")
|
||||
}
|
||||
|
||||
req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.CreateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreatePreparer prepares the Create request.
|
||||
func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
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.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
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 AccountsClient) 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 AccountsClient) CreateResponder(resp *http.Response) (result Account, 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 Cognitive Services account from the resource group.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only.
|
||||
func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Delete")
|
||||
}
|
||||
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", 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 AccountsClient) 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 AccountsClient) DeleteResponder(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
|
||||
}
|
||||
|
||||
// GetProperties returns a Cognitive Services account specified by the parameters.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only.
|
||||
func (client AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "GetProperties")
|
||||
}
|
||||
|
||||
req, err := client.GetPropertiesPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetPropertiesSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetPropertiesResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPropertiesPreparer prepares the GetProperties request.
|
||||
func (client AccountsClient) GetPropertiesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetPropertiesSender sends the GetProperties request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) GetPropertiesSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// GetPropertiesResponder handles the response to the GetProperties request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result Account, 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 returns all the resources of a particular type belonging to a subscription.
|
||||
func (client AccountsClient) List(ctx context.Context) (result AccountListResult, err error) {
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client AccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts", 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 AccountsClient) 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 AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, 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 returns all the resources of a particular type belonging to a resource group
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription.
|
||||
func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResult, err error) {
|
||||
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||
func (client AccountsClient) ListByResourceGroupPreparer(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 = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
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 AccountsClient) 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 AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// ListKeys lists the account keys for the specified Cognitive Services account.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Congitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only.
|
||||
func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "ListKeys")
|
||||
}
|
||||
|
||||
req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListKeysSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListKeysResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListKeysPreparer prepares the ListKeys request.
|
||||
func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListKeysSender sends the ListKeys request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListKeysResponder handles the response to the ListKeys request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// ListSkus list available SKUs for the requested Cognitive Services account
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only.
|
||||
func (client AccountsClient) ListSkus(ctx context.Context, resourceGroupName string, accountName string) (result AccountEnumerateSkusResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "ListSkus")
|
||||
}
|
||||
|
||||
req, err := client.ListSkusPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSkusSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListSkusResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListSkusPreparer prepares the ListSkus request.
|
||||
func (client AccountsClient) ListSkusPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSkusSender sends the ListSkus request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) ListSkusSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListSkusResponder handles the response to the ListSkus request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) ListSkusResponder(resp *http.Response) (result AccountEnumerateSkusResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// RegenerateKey regenerates the specified account key for the specified Cognitive Services account.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only. body is regenerate key parameters.
|
||||
func (client AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, body RegenerateKeyParameters) (result AccountKeys, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "RegenerateKey")
|
||||
}
|
||||
|
||||
req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.RegenerateKeySender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.RegenerateKeyResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RegenerateKeyPreparer prepares the RegenerateKey request.
|
||||
func (client AccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, body RegenerateKeyParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// RegenerateKeySender sends the RegenerateKey request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountKeys, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update updates a Cognitive Services account
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of the
|
||||
// cognitive services account within the specified resource group. Cognitive Services account names must be between 3
|
||||
// and 24 characters in length and use numbers and lower-case letters only. body is the parameters to provide for the
|
||||
// created account.
|
||||
func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, body AccountUpdateParameters) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Update")
|
||||
}
|
||||
|
||||
req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, body AccountUpdateParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2016-02-01-preview"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
// Package cognitiveservices implements the Azure ARM Cognitiveservices service API version 2016-02-01-preview.
|
||||
//
|
||||
// Cognitive Services Management Client
|
||||
package cognitiveservices
|
||||
|
||||
// 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 Cognitiveservices
|
||||
DefaultBaseURI = "https://management.azure.com"
|
||||
)
|
||||
|
||||
// BaseClient is the base client for Cognitiveservices.
|
||||
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,
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+336
@@ -0,0 +1,336 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// KeyName enumerates the values for key name.
|
||||
type KeyName string
|
||||
|
||||
const (
|
||||
// Key1 ...
|
||||
Key1 KeyName = "Key1"
|
||||
// Key2 ...
|
||||
Key2 KeyName = "Key2"
|
||||
)
|
||||
|
||||
// Kind enumerates the values for kind.
|
||||
type Kind string
|
||||
|
||||
const (
|
||||
// Academic ...
|
||||
Academic Kind = "Academic"
|
||||
// BingAutosuggest ...
|
||||
BingAutosuggest Kind = "Bing.Autosuggest"
|
||||
// BingSearch ...
|
||||
BingSearch Kind = "Bing.Search"
|
||||
// BingSpeech ...
|
||||
BingSpeech Kind = "Bing.Speech"
|
||||
// BingSpellCheck ...
|
||||
BingSpellCheck Kind = "Bing.SpellCheck"
|
||||
// ComputerVision ...
|
||||
ComputerVision Kind = "ComputerVision"
|
||||
// ContentModerator ...
|
||||
ContentModerator Kind = "ContentModerator"
|
||||
// Emotion ...
|
||||
Emotion Kind = "Emotion"
|
||||
// Face ...
|
||||
Face Kind = "Face"
|
||||
// LUIS ...
|
||||
LUIS Kind = "LUIS"
|
||||
// Recommendations ...
|
||||
Recommendations Kind = "Recommendations"
|
||||
// SpeakerRecognition ...
|
||||
SpeakerRecognition Kind = "SpeakerRecognition"
|
||||
// Speech ...
|
||||
Speech Kind = "Speech"
|
||||
// SpeechTranslation ...
|
||||
SpeechTranslation Kind = "SpeechTranslation"
|
||||
// TextAnalytics ...
|
||||
TextAnalytics Kind = "TextAnalytics"
|
||||
// TextTranslation ...
|
||||
TextTranslation Kind = "TextTranslation"
|
||||
// WebLM ...
|
||||
WebLM Kind = "WebLM"
|
||||
)
|
||||
|
||||
// ProvisioningState enumerates the values for provisioning state.
|
||||
type ProvisioningState string
|
||||
|
||||
const (
|
||||
// Creating ...
|
||||
Creating ProvisioningState = "Creating"
|
||||
// Failed ...
|
||||
Failed ProvisioningState = "Failed"
|
||||
// ResolvingDNS ...
|
||||
ResolvingDNS ProvisioningState = "ResolvingDNS"
|
||||
// Succeeded ...
|
||||
Succeeded ProvisioningState = "Succeeded"
|
||||
)
|
||||
|
||||
// SkuName enumerates the values for sku name.
|
||||
type SkuName string
|
||||
|
||||
const (
|
||||
// F0 ...
|
||||
F0 SkuName = "F0"
|
||||
// P0 ...
|
||||
P0 SkuName = "P0"
|
||||
// P1 ...
|
||||
P1 SkuName = "P1"
|
||||
// P2 ...
|
||||
P2 SkuName = "P2"
|
||||
// S0 ...
|
||||
S0 SkuName = "S0"
|
||||
// S1 ...
|
||||
S1 SkuName = "S1"
|
||||
// S2 ...
|
||||
S2 SkuName = "S2"
|
||||
// S3 ...
|
||||
S3 SkuName = "S3"
|
||||
// S4 ...
|
||||
S4 SkuName = "S4"
|
||||
// S5 ...
|
||||
S5 SkuName = "S5"
|
||||
// S6 ...
|
||||
S6 SkuName = "S6"
|
||||
)
|
||||
|
||||
// SkuTier enumerates the values for sku tier.
|
||||
type SkuTier string
|
||||
|
||||
const (
|
||||
// Free ...
|
||||
Free SkuTier = "Free"
|
||||
// Premium ...
|
||||
Premium SkuTier = "Premium"
|
||||
// Standard ...
|
||||
Standard SkuTier = "Standard"
|
||||
)
|
||||
|
||||
// Account cognitive Services Account is an Azure resource representing the provisioned account, its type, location and
|
||||
// SKU.
|
||||
type Account struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Etag - Entity Tag
|
||||
Etag *string `json:"etag,omitempty"`
|
||||
// ID - The id of the created account
|
||||
ID *string `json:"id,omitempty"`
|
||||
// Kind - Type of cognitive service account.
|
||||
Kind *string `json:"kind,omitempty"`
|
||||
// Location - The location of the resource
|
||||
Location *string `json:"location,omitempty"`
|
||||
// Name - The name of the created account
|
||||
Name *string `json:"name,omitempty"`
|
||||
*AccountProperties `json:"properties,omitempty"`
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
// Type - Resource type
|
||||
Type *string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON is the custom unmarshaler for Account struct.
|
||||
func (a *Account) 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["etag"]
|
||||
if v != nil {
|
||||
var etag string
|
||||
err = json.Unmarshal(*m["etag"], &etag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Etag = &etag
|
||||
}
|
||||
|
||||
v = m["id"]
|
||||
if v != nil {
|
||||
var ID string
|
||||
err = json.Unmarshal(*m["id"], &ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.ID = &ID
|
||||
}
|
||||
|
||||
v = m["kind"]
|
||||
if v != nil {
|
||||
var kind string
|
||||
err = json.Unmarshal(*m["kind"], &kind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Kind = &kind
|
||||
}
|
||||
|
||||
v = m["location"]
|
||||
if v != nil {
|
||||
var location string
|
||||
err = json.Unmarshal(*m["location"], &location)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Location = &location
|
||||
}
|
||||
|
||||
v = m["name"]
|
||||
if v != nil {
|
||||
var name string
|
||||
err = json.Unmarshal(*m["name"], &name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Name = &name
|
||||
}
|
||||
|
||||
v = m["properties"]
|
||||
if v != nil {
|
||||
var properties AccountProperties
|
||||
err = json.Unmarshal(*m["properties"], &properties)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.AccountProperties = &properties
|
||||
}
|
||||
|
||||
v = m["sku"]
|
||||
if v != nil {
|
||||
var sku Sku
|
||||
err = json.Unmarshal(*m["sku"], &sku)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Sku = &sku
|
||||
}
|
||||
|
||||
v = m["tags"]
|
||||
if v != nil {
|
||||
var tags map[string]*string
|
||||
err = json.Unmarshal(*m["tags"], &tags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Tags = &tags
|
||||
}
|
||||
|
||||
v = m["type"]
|
||||
if v != nil {
|
||||
var typeVar string
|
||||
err = json.Unmarshal(*m["type"], &typeVar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Type = &typeVar
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccountCreateParameters the parameters to provide for the account.
|
||||
type AccountCreateParameters struct {
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Kind - Required. Indicates the type of cognitive service account. Possible values include: 'Academic', 'BingAutosuggest', 'BingSearch', 'BingSpeech', 'BingSpellCheck', 'ComputerVision', 'ContentModerator', 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
|
||||
Kind Kind `json:"kind,omitempty"`
|
||||
// Location - Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource cannot be changed once it is created, but if an identical geo region is specified on update the request will succeed.
|
||||
Location *string `json:"location,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
// Properties - Must exist in the request. Must not be null.
|
||||
Properties *map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// AccountEnumerateSkusResult the list of cognitive services accounts operation response.
|
||||
type AccountEnumerateSkusResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Value - Gets the list of Cognitive Services accounts and their properties.
|
||||
Value *[]ResourceAndSku `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// AccountKeys the access keys for the cognitive services account.
|
||||
type AccountKeys struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Key1 - Gets the value of key 1.
|
||||
Key1 *string `json:"key1,omitempty"`
|
||||
// Key2 - Gets the value of key 2.
|
||||
Key2 *string `json:"key2,omitempty"`
|
||||
}
|
||||
|
||||
// AccountListResult the list of cognitive services accounts operation response.
|
||||
type AccountListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Value - Gets the list of Cognitive Services accounts and their properties.
|
||||
Value *[]Account `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// AccountProperties ...
|
||||
type AccountProperties struct {
|
||||
// ProvisioningState - Gets the status of the cognitive services account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded', 'Failed'
|
||||
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
|
||||
// Endpoint - Endpoint of the created account
|
||||
Endpoint *string `json:"endpoint,omitempty"`
|
||||
}
|
||||
|
||||
// AccountUpdateParameters the parameters to provide for the account.
|
||||
type AccountUpdateParameters struct {
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// Error ...
|
||||
type Error struct {
|
||||
Error *ErrorBody `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorBody ...
|
||||
type ErrorBody struct {
|
||||
// Code - error code
|
||||
Code *string `json:"code,omitempty"`
|
||||
// Message - error message
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// RegenerateKeyParameters regenerate key parameters.
|
||||
type RegenerateKeyParameters struct {
|
||||
// KeyName - key name to generate (Key1|Key2). Possible values include: 'Key1', 'Key2'
|
||||
KeyName KeyName `json:"keyName,omitempty"`
|
||||
}
|
||||
|
||||
// ResourceAndSku ...
|
||||
type ResourceAndSku struct {
|
||||
// ResourceType - Resource Namespace and Type
|
||||
ResourceType *string `json:"resourceType,omitempty"`
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
}
|
||||
|
||||
// Sku the SKU of the cognitive services account.
|
||||
type Sku struct {
|
||||
// Name - Gets or sets the sku name. Required for account creation, optional for update. Possible values include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6'
|
||||
Name SkuName `json:"name,omitempty"`
|
||||
// Tier - Gets the sku tier. This is based on the SKU name. Possible values include: 'Free', 'Standard', 'Premium'
|
||||
Tier SkuTier `json:"tier,omitempty"`
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
}
|
||||
Generated
Vendored
+759
@@ -0,0 +1,759 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AccountsClient is the cognitive Services Management Client
|
||||
type AccountsClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewAccountsClient creates an instance of the AccountsClient client.
|
||||
func NewAccountsClient(subscriptionID string) AccountsClient {
|
||||
return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client.
|
||||
func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient {
|
||||
return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// Create create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for
|
||||
// developer to access intelligent APIs. It's also the resource type for billing.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account. parameters is the parameters to provide for the created account.
|
||||
func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}},
|
||||
{TargetValue: parameters,
|
||||
Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Create")
|
||||
}
|
||||
|
||||
req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.CreateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreatePreparer prepares the Create request.
|
||||
func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
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.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
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 AccountsClient) 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 AccountsClient) CreateResponder(resp *http.Response) (result Account, 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 Cognitive Services account from the resource group.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account.
|
||||
func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Delete")
|
||||
}
|
||||
|
||||
req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", 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 AccountsClient) 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 AccountsClient) DeleteResponder(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
|
||||
}
|
||||
|
||||
// GetProperties returns a Cognitive Services account specified by the parameters.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account.
|
||||
func (client AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "GetProperties")
|
||||
}
|
||||
|
||||
req, err := client.GetPropertiesPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetPropertiesSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetPropertiesResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPropertiesPreparer prepares the GetProperties request.
|
||||
func (client AccountsClient) GetPropertiesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// GetPropertiesSender sends the GetProperties request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) GetPropertiesSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// GetPropertiesResponder handles the response to the GetProperties request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result Account, 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 returns all the resources of a particular type belonging to a subscription.
|
||||
func (client AccountsClient) List(ctx context.Context) (result AccountListResultPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.alr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.alr, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client AccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts", 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 AccountsClient) 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 AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client AccountsClient) listNextResults(lastResults AccountListResult) (result AccountListResult, err error) {
|
||||
req, err := lastResults.accountListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client AccountsClient) ListComplete(ctx context.Context) (result AccountListResultIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroup returns all the resources of a particular type belonging to a resource group
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription.
|
||||
func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResultPage, err error) {
|
||||
result.fn = client.listByResourceGroupNextResults
|
||||
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.alr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.alr, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||
func (client AccountsClient) ListByResourceGroupPreparer(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 = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
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 AccountsClient) 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 AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||
func (client AccountsClient) listByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) {
|
||||
req, err := lastResults.accountListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListByResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListByResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AccountListResultIterator, err error) {
|
||||
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||
return
|
||||
}
|
||||
|
||||
// ListKeys lists the account keys for the specified Cognitive Services account.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account.
|
||||
func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "ListKeys")
|
||||
}
|
||||
|
||||
req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListKeysSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListKeysResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListKeysPreparer prepares the ListKeys request.
|
||||
func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListKeysSender sends the ListKeys request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListKeysResponder handles the response to the ListKeys request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// ListSkus list available SKUs for the requested Cognitive Services account
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account.
|
||||
func (client AccountsClient) ListSkus(ctx context.Context, resourceGroupName string, accountName string) (result AccountEnumerateSkusResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "ListSkus")
|
||||
}
|
||||
|
||||
req, err := client.ListSkusPreparer(ctx, resourceGroupName, accountName)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSkusSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListSkusResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListSkusPreparer prepares the ListSkus request.
|
||||
func (client AccountsClient) ListSkusPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSkusSender sends the ListSkus request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) ListSkusSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListSkusResponder handles the response to the ListSkus request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) ListSkusResponder(resp *http.Response) (result AccountEnumerateSkusResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// RegenerateKey regenerates the specified account key for the specified Cognitive Services account.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account. parameters is regenerate key parameters.
|
||||
func (client AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, parameters RegenerateKeyParameters) (result AccountKeys, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "RegenerateKey")
|
||||
}
|
||||
|
||||
req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.RegenerateKeySender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.RegenerateKeyResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RegenerateKeyPreparer prepares the RegenerateKey request.
|
||||
func (client AccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, parameters RegenerateKeyParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// RegenerateKeySender sends the RegenerateKey request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountKeys, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update updates a Cognitive Services account
|
||||
//
|
||||
// resourceGroupName is the name of the resource group within the user's subscription. accountName is the name of
|
||||
// Cognitive Services account. parameters is the parameters to provide for the created account.
|
||||
func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: accountName,
|
||||
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "accountName", Name: validation.MinLength, Rule: 2, Chain: nil},
|
||||
{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.AccountsClient", "Update")
|
||||
}
|
||||
|
||||
req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"accountName": autorest.Encode("path", accountName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req,
|
||||
azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CheckSkuAvailabilityClient is the cognitive Services Management Client
|
||||
type CheckSkuAvailabilityClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewCheckSkuAvailabilityClient creates an instance of the CheckSkuAvailabilityClient client.
|
||||
func NewCheckSkuAvailabilityClient(subscriptionID string) CheckSkuAvailabilityClient {
|
||||
return NewCheckSkuAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewCheckSkuAvailabilityClientWithBaseURI creates an instance of the CheckSkuAvailabilityClient client.
|
||||
func NewCheckSkuAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckSkuAvailabilityClient {
|
||||
return CheckSkuAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List check available SKUs.
|
||||
//
|
||||
// location is resource location. parameters is check SKU Availablity POST body.
|
||||
func (client CheckSkuAvailabilityClient) List(ctx context.Context, location string, parameters CheckSkuAvailabilityParameter) (result CheckSkuAvailabilityResultList, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: parameters,
|
||||
Constraints: []validation.Constraint{{Target: "parameters.Skus", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "cognitiveservices.CheckSkuAvailabilityClient", "List")
|
||||
}
|
||||
|
||||
req, err := client.ListPreparer(ctx, location, parameters)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.CheckSkuAvailabilityClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.CheckSkuAvailabilityClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.CheckSkuAvailabilityClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client CheckSkuAvailabilityClient) ListPreparer(ctx context.Context, location string, parameters CheckSkuAvailabilityParameter) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"location": autorest.Encode("path", location),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
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 CheckSkuAvailabilityClient) 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 CheckSkuAvailabilityClient) ListResponder(resp *http.Response) (result CheckSkuAvailabilityResultList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
// Package cognitiveservices implements the Azure ARM Cognitiveservices service API version 2017-04-18.
|
||||
//
|
||||
// Cognitive Services Management Client
|
||||
package cognitiveservices
|
||||
|
||||
// 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 Cognitiveservices
|
||||
DefaultBaseURI = "https://management.azure.com"
|
||||
)
|
||||
|
||||
// BaseClient is the base client for Cognitiveservices.
|
||||
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,
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+614
@@ -0,0 +1,614 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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/to"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// KeyName enumerates the values for key name.
|
||||
type KeyName string
|
||||
|
||||
const (
|
||||
// Key1 ...
|
||||
Key1 KeyName = "Key1"
|
||||
// Key2 ...
|
||||
Key2 KeyName = "Key2"
|
||||
)
|
||||
|
||||
// Kind enumerates the values for kind.
|
||||
type Kind string
|
||||
|
||||
const (
|
||||
// Academic ...
|
||||
Academic Kind = "Academic"
|
||||
// BingAutosuggest ...
|
||||
BingAutosuggest Kind = "Bing.Autosuggest"
|
||||
// BingAutosuggestv7 ...
|
||||
BingAutosuggestv7 Kind = "Bing.Autosuggest.v7"
|
||||
// BingCustomSearch ...
|
||||
BingCustomSearch Kind = "Bing.CustomSearch"
|
||||
// BingSearch ...
|
||||
BingSearch Kind = "Bing.Search"
|
||||
// BingSearchv7 ...
|
||||
BingSearchv7 Kind = "Bing.Search.v7"
|
||||
// BingSpeech ...
|
||||
BingSpeech Kind = "Bing.Speech"
|
||||
// BingSpellCheck ...
|
||||
BingSpellCheck Kind = "Bing.SpellCheck"
|
||||
// BingSpellCheckv7 ...
|
||||
BingSpellCheckv7 Kind = "Bing.SpellCheck.v7"
|
||||
// ComputerVision ...
|
||||
ComputerVision Kind = "ComputerVision"
|
||||
// ContentModerator ...
|
||||
ContentModerator Kind = "ContentModerator"
|
||||
// CustomSpeech ...
|
||||
CustomSpeech Kind = "CustomSpeech"
|
||||
// Emotion ...
|
||||
Emotion Kind = "Emotion"
|
||||
// Face ...
|
||||
Face Kind = "Face"
|
||||
// LUIS ...
|
||||
LUIS Kind = "LUIS"
|
||||
// Recommendations ...
|
||||
Recommendations Kind = "Recommendations"
|
||||
// SpeakerRecognition ...
|
||||
SpeakerRecognition Kind = "SpeakerRecognition"
|
||||
// Speech ...
|
||||
Speech Kind = "Speech"
|
||||
// SpeechTranslation ...
|
||||
SpeechTranslation Kind = "SpeechTranslation"
|
||||
// TextAnalytics ...
|
||||
TextAnalytics Kind = "TextAnalytics"
|
||||
// TextTranslation ...
|
||||
TextTranslation Kind = "TextTranslation"
|
||||
// WebLM ...
|
||||
WebLM Kind = "WebLM"
|
||||
)
|
||||
|
||||
// ProvisioningState enumerates the values for provisioning state.
|
||||
type ProvisioningState string
|
||||
|
||||
const (
|
||||
// Creating ...
|
||||
Creating ProvisioningState = "Creating"
|
||||
// Deleting ...
|
||||
Deleting ProvisioningState = "Deleting"
|
||||
// Failed ...
|
||||
Failed ProvisioningState = "Failed"
|
||||
// Moving ...
|
||||
Moving ProvisioningState = "Moving"
|
||||
// ResolvingDNS ...
|
||||
ResolvingDNS ProvisioningState = "ResolvingDNS"
|
||||
// Succeeded ...
|
||||
Succeeded ProvisioningState = "Succeeded"
|
||||
)
|
||||
|
||||
// SkuName enumerates the values for sku name.
|
||||
type SkuName string
|
||||
|
||||
const (
|
||||
// F0 ...
|
||||
F0 SkuName = "F0"
|
||||
// P0 ...
|
||||
P0 SkuName = "P0"
|
||||
// P1 ...
|
||||
P1 SkuName = "P1"
|
||||
// P2 ...
|
||||
P2 SkuName = "P2"
|
||||
// S0 ...
|
||||
S0 SkuName = "S0"
|
||||
// S1 ...
|
||||
S1 SkuName = "S1"
|
||||
// S2 ...
|
||||
S2 SkuName = "S2"
|
||||
// S3 ...
|
||||
S3 SkuName = "S3"
|
||||
// S4 ...
|
||||
S4 SkuName = "S4"
|
||||
// S5 ...
|
||||
S5 SkuName = "S5"
|
||||
// S6 ...
|
||||
S6 SkuName = "S6"
|
||||
)
|
||||
|
||||
// SkuTier enumerates the values for sku tier.
|
||||
type SkuTier string
|
||||
|
||||
const (
|
||||
// Free ...
|
||||
Free SkuTier = "Free"
|
||||
// Premium ...
|
||||
Premium SkuTier = "Premium"
|
||||
// Standard ...
|
||||
Standard SkuTier = "Standard"
|
||||
)
|
||||
|
||||
// Account cognitive Services Account is an Azure resource representing the provisioned account, its type, location and
|
||||
// SKU.
|
||||
type Account struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Etag - Entity Tag
|
||||
Etag *string `json:"etag,omitempty"`
|
||||
// ID - The id of the created account
|
||||
ID *string `json:"id,omitempty"`
|
||||
// Kind - Type of cognitive service account.
|
||||
Kind *string `json:"kind,omitempty"`
|
||||
// Location - The location of the resource
|
||||
Location *string `json:"location,omitempty"`
|
||||
// Name - The name of the created account
|
||||
Name *string `json:"name,omitempty"`
|
||||
// AccountProperties - Properties of Cognitive Services account.
|
||||
*AccountProperties `json:"properties,omitempty"`
|
||||
// Sku - The SKU of Cognitive Services account.
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
// Type - Resource type
|
||||
Type *string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON is the custom unmarshaler for Account struct.
|
||||
func (a *Account) 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["etag"]
|
||||
if v != nil {
|
||||
var etag string
|
||||
err = json.Unmarshal(*m["etag"], &etag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Etag = &etag
|
||||
}
|
||||
|
||||
v = m["id"]
|
||||
if v != nil {
|
||||
var ID string
|
||||
err = json.Unmarshal(*m["id"], &ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.ID = &ID
|
||||
}
|
||||
|
||||
v = m["kind"]
|
||||
if v != nil {
|
||||
var kind string
|
||||
err = json.Unmarshal(*m["kind"], &kind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Kind = &kind
|
||||
}
|
||||
|
||||
v = m["location"]
|
||||
if v != nil {
|
||||
var location string
|
||||
err = json.Unmarshal(*m["location"], &location)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Location = &location
|
||||
}
|
||||
|
||||
v = m["name"]
|
||||
if v != nil {
|
||||
var name string
|
||||
err = json.Unmarshal(*m["name"], &name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Name = &name
|
||||
}
|
||||
|
||||
v = m["properties"]
|
||||
if v != nil {
|
||||
var properties AccountProperties
|
||||
err = json.Unmarshal(*m["properties"], &properties)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.AccountProperties = &properties
|
||||
}
|
||||
|
||||
v = m["sku"]
|
||||
if v != nil {
|
||||
var sku Sku
|
||||
err = json.Unmarshal(*m["sku"], &sku)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Sku = &sku
|
||||
}
|
||||
|
||||
v = m["tags"]
|
||||
if v != nil {
|
||||
var tags map[string]*string
|
||||
err = json.Unmarshal(*m["tags"], &tags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Tags = &tags
|
||||
}
|
||||
|
||||
v = m["type"]
|
||||
if v != nil {
|
||||
var typeVar string
|
||||
err = json.Unmarshal(*m["type"], &typeVar)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Type = &typeVar
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccountCreateParameters the parameters to provide for the account.
|
||||
type AccountCreateParameters struct {
|
||||
// Sku - Required. Gets or sets the SKU of the resource.
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Kind - Required. Gets or sets the Kind of the resource. Possible values include: 'Academic', 'BingAutosuggest', 'BingAutosuggestv7', 'BingCustomSearch', 'BingSearch', 'BingSearchv7', 'BingSpeech', 'BingSpellCheck', 'BingSpellCheckv7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
|
||||
Kind Kind `json:"kind,omitempty"`
|
||||
// Location - Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource cannot be changed once it is created, but if an identical geo region is specified on update the request will succeed.
|
||||
Location *string `json:"location,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
// Properties - Must exist in the request. Must be an empty object. Must not be null.
|
||||
Properties *map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// AccountEnumerateSkusResult the list of cognitive services accounts operation response.
|
||||
type AccountEnumerateSkusResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Value - Gets the list of Cognitive Services accounts and their properties.
|
||||
Value *[]ResourceAndSku `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// AccountKeys the access keys for the cognitive services account.
|
||||
type AccountKeys struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Key1 - Gets the value of key 1.
|
||||
Key1 *string `json:"key1,omitempty"`
|
||||
// Key2 - Gets the value of key 2.
|
||||
Key2 *string `json:"key2,omitempty"`
|
||||
}
|
||||
|
||||
// AccountListResult the list of cognitive services accounts operation response.
|
||||
type AccountListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// NextLink - The link used to get the next page of accounts.
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
// Value - Gets the list of Cognitive Services accounts and their properties.
|
||||
Value *[]Account `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// AccountListResultIterator provides access to a complete listing of Account values.
|
||||
type AccountListResultIterator struct {
|
||||
i int
|
||||
page AccountListResultPage
|
||||
}
|
||||
|
||||
// Next advances to the next value. If there was an error making
|
||||
// the request the iterator does not advance and the error is returned.
|
||||
func (iter *AccountListResultIterator) Next() error {
|
||||
iter.i++
|
||||
if iter.i < len(iter.page.Values()) {
|
||||
return nil
|
||||
}
|
||||
err := iter.page.Next()
|
||||
if err != nil {
|
||||
iter.i--
|
||||
return err
|
||||
}
|
||||
iter.i = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the enumeration should be started or is not yet complete.
|
||||
func (iter AccountListResultIterator) NotDone() bool {
|
||||
return iter.page.NotDone() && iter.i < len(iter.page.Values())
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (iter AccountListResultIterator) Response() AccountListResult {
|
||||
return iter.page.Response()
|
||||
}
|
||||
|
||||
// Value returns the current value or a zero-initialized value if the
|
||||
// iterator has advanced beyond the end of the collection.
|
||||
func (iter AccountListResultIterator) Value() Account {
|
||||
if !iter.page.NotDone() {
|
||||
return Account{}
|
||||
}
|
||||
return iter.page.Values()[iter.i]
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the ListResult contains no values.
|
||||
func (alr AccountListResult) IsEmpty() bool {
|
||||
return alr.Value == nil || len(*alr.Value) == 0
|
||||
}
|
||||
|
||||
// accountListResultPreparer prepares a request to retrieve the next set of results.
|
||||
// It returns nil if no more results exist.
|
||||
func (alr AccountListResult) accountListResultPreparer() (*http.Request, error) {
|
||||
if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(alr.NextLink)))
|
||||
}
|
||||
|
||||
// AccountListResultPage contains a page of Account values.
|
||||
type AccountListResultPage struct {
|
||||
fn func(AccountListResult) (AccountListResult, error)
|
||||
alr AccountListResult
|
||||
}
|
||||
|
||||
// Next advances to the next page of values. If there was an error making
|
||||
// the request the page does not advance and the error is returned.
|
||||
func (page *AccountListResultPage) Next() error {
|
||||
next, err := page.fn(page.alr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
page.alr = next
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the page enumeration should be started or is not yet complete.
|
||||
func (page AccountListResultPage) NotDone() bool {
|
||||
return !page.alr.IsEmpty()
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (page AccountListResultPage) Response() AccountListResult {
|
||||
return page.alr
|
||||
}
|
||||
|
||||
// Values returns the slice of values for the current page or nil if there are no values.
|
||||
func (page AccountListResultPage) Values() []Account {
|
||||
if page.alr.IsEmpty() {
|
||||
return nil
|
||||
}
|
||||
return *page.alr.Value
|
||||
}
|
||||
|
||||
// AccountProperties properties of Cognitive Services account.
|
||||
type AccountProperties struct {
|
||||
// ProvisioningState - Gets the status of the cognitive services account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Moving', 'Deleting', 'Succeeded', 'Failed'
|
||||
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
|
||||
// Endpoint - Endpoint of the created account.
|
||||
Endpoint *string `json:"endpoint,omitempty"`
|
||||
// InternalID - The internal identifier.
|
||||
InternalID *string `json:"internalId,omitempty"`
|
||||
}
|
||||
|
||||
// AccountUpdateParameters the parameters to provide for the account.
|
||||
type AccountUpdateParameters struct {
|
||||
// Sku - Gets or sets the SKU of the resource.
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
// Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters.
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// CheckSkuAvailabilityParameter check SKU availability parameter.
|
||||
type CheckSkuAvailabilityParameter struct {
|
||||
// Skus - The SKU of the resource.
|
||||
Skus *[]SkuName `json:"skus,omitempty"`
|
||||
// Kind - The Kind of the resource. Possible values include: 'Academic', 'BingAutosuggest', 'BingAutosuggestv7', 'BingCustomSearch', 'BingSearch', 'BingSearchv7', 'BingSpeech', 'BingSpellCheck', 'BingSpellCheckv7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
|
||||
Kind Kind `json:"kind,omitempty"`
|
||||
// Type - The Type of the resource.
|
||||
Type *string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// CheckSkuAvailabilityResult check SKU availability result.
|
||||
type CheckSkuAvailabilityResult struct {
|
||||
// Kind - The Kind of the resource. Possible values include: 'Academic', 'BingAutosuggest', 'BingAutosuggestv7', 'BingCustomSearch', 'BingSearch', 'BingSearchv7', 'BingSpeech', 'BingSpellCheck', 'BingSpellCheckv7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
|
||||
Kind Kind `json:"kind,omitempty"`
|
||||
// Type - The Type of the resource.
|
||||
Type *string `json:"type,omitempty"`
|
||||
// SkuName - The SKU of Cognitive Services account. Possible values include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6'
|
||||
SkuName SkuName `json:"skuName,omitempty"`
|
||||
// SkuAvailable - Indicates the given SKU is available or not.
|
||||
SkuAvailable *bool `json:"skuAvailable,omitempty"`
|
||||
// Reason - Reason why the SKU is not available.
|
||||
Reason *string `json:"reason,omitempty"`
|
||||
// Message - Additional error message.
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// CheckSkuAvailabilityResultList check SKU availability result list.
|
||||
type CheckSkuAvailabilityResultList struct {
|
||||
autorest.Response `json:"-"`
|
||||
// Value - Check SKU availability result list.
|
||||
Value *[]CheckSkuAvailabilityResult `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// Error cognitive Services error object.
|
||||
type Error struct {
|
||||
// Error - The error body.
|
||||
Error *ErrorBody `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorBody cognitive Services error body.
|
||||
type ErrorBody struct {
|
||||
// Code - error code
|
||||
Code *string `json:"code,omitempty"`
|
||||
// Message - error message
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// OperationDisplayInfo the operation supported by Cognitive Services.
|
||||
type OperationDisplayInfo struct {
|
||||
// Description - The description of the operation.
|
||||
Description *string `json:"description,omitempty"`
|
||||
// Operation - The action that users can perform, based on their permission level.
|
||||
Operation *string `json:"operation,omitempty"`
|
||||
// Provider - Service provider: Microsoft Cognitive Services.
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
// Resource - Resource on which the operation is performed.
|
||||
Resource *string `json:"resource,omitempty"`
|
||||
}
|
||||
|
||||
// OperationEntity the operation supported by Cognitive Services.
|
||||
type OperationEntity struct {
|
||||
// Name - Operation name: {provider}/{resource}/{operation}.
|
||||
Name *string `json:"name,omitempty"`
|
||||
// Display - The operation supported by Cognitive Services.
|
||||
Display *OperationDisplayInfo `json:"display,omitempty"`
|
||||
// Origin - The origin of the operation.
|
||||
Origin *string `json:"origin,omitempty"`
|
||||
// Properties - Additional properties.
|
||||
Properties *map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// OperationEntityListResult the list of cognitive services accounts operation response.
|
||||
type OperationEntityListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
// NextLink - The link used to get the next page of operations.
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
// Value - The list of operations.
|
||||
Value *[]OperationEntity `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// OperationEntityListResultIterator provides access to a complete listing of OperationEntity values.
|
||||
type OperationEntityListResultIterator struct {
|
||||
i int
|
||||
page OperationEntityListResultPage
|
||||
}
|
||||
|
||||
// Next advances to the next value. If there was an error making
|
||||
// the request the iterator does not advance and the error is returned.
|
||||
func (iter *OperationEntityListResultIterator) Next() error {
|
||||
iter.i++
|
||||
if iter.i < len(iter.page.Values()) {
|
||||
return nil
|
||||
}
|
||||
err := iter.page.Next()
|
||||
if err != nil {
|
||||
iter.i--
|
||||
return err
|
||||
}
|
||||
iter.i = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the enumeration should be started or is not yet complete.
|
||||
func (iter OperationEntityListResultIterator) NotDone() bool {
|
||||
return iter.page.NotDone() && iter.i < len(iter.page.Values())
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (iter OperationEntityListResultIterator) Response() OperationEntityListResult {
|
||||
return iter.page.Response()
|
||||
}
|
||||
|
||||
// Value returns the current value or a zero-initialized value if the
|
||||
// iterator has advanced beyond the end of the collection.
|
||||
func (iter OperationEntityListResultIterator) Value() OperationEntity {
|
||||
if !iter.page.NotDone() {
|
||||
return OperationEntity{}
|
||||
}
|
||||
return iter.page.Values()[iter.i]
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the ListResult contains no values.
|
||||
func (oelr OperationEntityListResult) IsEmpty() bool {
|
||||
return oelr.Value == nil || len(*oelr.Value) == 0
|
||||
}
|
||||
|
||||
// operationEntityListResultPreparer prepares a request to retrieve the next set of results.
|
||||
// It returns nil if no more results exist.
|
||||
func (oelr OperationEntityListResult) operationEntityListResultPreparer() (*http.Request, error) {
|
||||
if oelr.NextLink == nil || len(to.String(oelr.NextLink)) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(oelr.NextLink)))
|
||||
}
|
||||
|
||||
// OperationEntityListResultPage contains a page of OperationEntity values.
|
||||
type OperationEntityListResultPage struct {
|
||||
fn func(OperationEntityListResult) (OperationEntityListResult, error)
|
||||
oelr OperationEntityListResult
|
||||
}
|
||||
|
||||
// Next advances to the next page of values. If there was an error making
|
||||
// the request the page does not advance and the error is returned.
|
||||
func (page *OperationEntityListResultPage) Next() error {
|
||||
next, err := page.fn(page.oelr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
page.oelr = next
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotDone returns true if the page enumeration should be started or is not yet complete.
|
||||
func (page OperationEntityListResultPage) NotDone() bool {
|
||||
return !page.oelr.IsEmpty()
|
||||
}
|
||||
|
||||
// Response returns the raw server response from the last page request.
|
||||
func (page OperationEntityListResultPage) Response() OperationEntityListResult {
|
||||
return page.oelr
|
||||
}
|
||||
|
||||
// Values returns the slice of values for the current page or nil if there are no values.
|
||||
func (page OperationEntityListResultPage) Values() []OperationEntity {
|
||||
if page.oelr.IsEmpty() {
|
||||
return nil
|
||||
}
|
||||
return *page.oelr.Value
|
||||
}
|
||||
|
||||
// RegenerateKeyParameters regenerate key parameters.
|
||||
type RegenerateKeyParameters struct {
|
||||
// KeyName - key name to generate (Key1|Key2). Possible values include: 'Key1', 'Key2'
|
||||
KeyName KeyName `json:"keyName,omitempty"`
|
||||
}
|
||||
|
||||
// ResourceAndSku cognitive Services resource type and SKU.
|
||||
type ResourceAndSku struct {
|
||||
// ResourceType - Resource Namespace and Type
|
||||
ResourceType *string `json:"resourceType,omitempty"`
|
||||
// Sku - The SKU of Cognitive Services account.
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
}
|
||||
|
||||
// Sku the SKU of the cognitive services account.
|
||||
type Sku struct {
|
||||
// Name - Gets or sets the sku name. Required for account creation, optional for update. Possible values include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6'
|
||||
Name SkuName `json:"name,omitempty"`
|
||||
// Tier - Gets the sku tier. This is based on the SKU name. Possible values include: 'Free', 'Standard', 'Premium'
|
||||
Tier SkuTier `json:"tier,omitempty"`
|
||||
}
|
||||
Generated
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// OperationsClient is the cognitive Services Management Client
|
||||
type OperationsClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewOperationsClient creates an instance of the OperationsClient client.
|
||||
func NewOperationsClient(subscriptionID string) OperationsClient {
|
||||
return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client.
|
||||
func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
|
||||
return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List lists all the available Cognitive Services account operations.
|
||||
func (client OperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) {
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.oelr.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.oelr, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
const APIVersion = "2017-04-18"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPath("/providers/Microsoft.CognitiveServices/operations"),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return 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 OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client OperationsClient) listNextResults(lastResults OperationEntityListResult) (result OperationEntityListResult, err error) {
|
||||
req, err := lastResults.operationEntityListResultPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "cognitiveservices.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) {
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package cognitiveservices
|
||||
|
||||
// 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"
|
||||
}
|
||||
Reference in New Issue
Block a user