diff --git a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/documentdbapi/interfaces.go b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/documentdbapi/interfaces.go index a1540a237691..aecd9557b129 100644 --- a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/documentdbapi/interfaces.go +++ b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/documentdbapi/interfaces.go @@ -233,6 +233,19 @@ type GremlinResourcesClientAPI interface { var _ GremlinResourcesClientAPI = (*documentdb.GremlinResourcesClient)(nil) +// NotebookWorkspacesClientAPI contains the set of methods on the NotebookWorkspacesClient type. +type NotebookWorkspacesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters documentdb.NotebookWorkspaceCreateUpdateParameters) (result documentdb.NotebookWorkspacesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspace, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceListResult, err error) + ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceConnectionInfoResult, err error) + RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesRegenerateAuthTokenFuture, err error) + Start(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesStartFuture, err error) +} + +var _ NotebookWorkspacesClientAPI = (*documentdb.NotebookWorkspacesClient)(nil) + // PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. type PrivateLinkResourcesClientAPI interface { Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result documentdb.PrivateLinkResource, err error) diff --git a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/models.go b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/models.go index baf6ed44806b..5b7f5943c8ed 100644 --- a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/models.go +++ b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/models.go @@ -3290,6 +3290,211 @@ type MongoIndexOptions struct { Unique *bool `json:"unique,omitempty"` } +// NotebookWorkspace a notebook workspace resource +type NotebookWorkspace struct { + autorest.Response `json:"-"` + // NotebookWorkspaceProperties - Resource properties. + *NotebookWorkspaceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspace. +func (nw NotebookWorkspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nw.NotebookWorkspaceProperties != nil { + objectMap["properties"] = nw.NotebookWorkspaceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NotebookWorkspace struct. +func (nw *NotebookWorkspace) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var notebookWorkspaceProperties NotebookWorkspaceProperties + err = json.Unmarshal(*v, ¬ebookWorkspaceProperties) + if err != nil { + return err + } + nw.NotebookWorkspaceProperties = ¬ebookWorkspaceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nw.Type = &typeVar + } + } + } + + return nil +} + +// NotebookWorkspaceConnectionInfoResult the connection info for the given notebook workspace +type NotebookWorkspaceConnectionInfoResult struct { + autorest.Response `json:"-"` + // AuthToken - READ-ONLY; Specifies auth token used for connecting to Notebook server (uses token-based auth). + AuthToken *string `json:"authToken,omitempty"` + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` +} + +// NotebookWorkspaceCreateUpdateParameters parameters to create a notebook workspace resource +type NotebookWorkspaceCreateUpdateParameters struct { + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// NotebookWorkspaceListResult a list of notebook workspace resources +type NotebookWorkspaceListResult struct { + autorest.Response `json:"-"` + // Value - Array of notebook workspace resources + Value *[]NotebookWorkspace `json:"value,omitempty"` +} + +// NotebookWorkspaceProperties properties of a notebook workspace resource. +type NotebookWorkspaceProperties struct { + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` + // Status - READ-ONLY; Status of the notebook workspace. Possible values are: Creating, Online, Deleting, Failed, Updating. + Status *string `json:"status,omitempty"` +} + +// NotebookWorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *NotebookWorkspacesCreateOrUpdateFuture) Result(client NotebookWorkspacesClient) (nw NotebookWorkspace, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if nw.Response.Response, err = future.GetResult(sender); err == nil && nw.Response.Response.StatusCode != http.StatusNoContent { + nw, err = client.CreateOrUpdateResponder(nw.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", nw.Response.Response, "Failure responding to request") + } + } + return +} + +// NotebookWorkspacesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *NotebookWorkspacesDeleteFuture) Result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// NotebookWorkspacesRegenerateAuthTokenFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type NotebookWorkspacesRegenerateAuthTokenFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *NotebookWorkspacesRegenerateAuthTokenFuture) Result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesRegenerateAuthTokenFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesRegenerateAuthTokenFuture") + return + } + ar.Response = future.Response() + return +} + +// NotebookWorkspacesStartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type NotebookWorkspacesStartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *NotebookWorkspacesStartFuture) Result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesStartFuture") + return + } + ar.Response = future.Response() + return +} + // Operation REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} @@ -3648,6 +3853,10 @@ type PrivateEndpointConnectionProperties struct { PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // GroupID - Group id of the private endpoint. + GroupID *string `json:"groupId,omitempty"` + // ProvisioningState - Provisioning state of the private endpoint. + ProvisioningState *string `json:"provisioningState,omitempty"` } // PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results @@ -3794,6 +4003,8 @@ type PrivateLinkResourceProperties struct { GroupID *string `json:"groupId,omitempty"` // RequiredMembers - READ-ONLY; The private link resource required member names. RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The private link resource required zone names. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` } // PrivateLinkServiceConnectionStateProperty connection State of the Private Endpoint Connection. diff --git a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/notebookworkspaces.go b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/notebookworkspaces.go new file mode 100644 index 000000000000..ef2a4cac2827 --- /dev/null +++ b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/notebookworkspaces.go @@ -0,0 +1,680 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotebookWorkspacesClient is the azure Cosmos DB Database Service Resource Provider REST API +type NotebookWorkspacesClient struct { + BaseClient +} + +// NewNotebookWorkspacesClient creates an instance of the NotebookWorkspacesClient client. +func NewNotebookWorkspacesClient(subscriptionID string, subscriptionID1 string) NotebookWorkspacesClient { + return NewNotebookWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID, subscriptionID1) +} + +// NewNotebookWorkspacesClientWithBaseURI creates an instance of the NotebookWorkspacesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewNotebookWorkspacesClientWithBaseURI(baseURI string, subscriptionID string, subscriptionID1 string) NotebookWorkspacesClient { + return NotebookWorkspacesClient{NewWithBaseURI(baseURI, subscriptionID, subscriptionID1)} +} + +// CreateOrUpdate creates the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// notebookCreateUpdateParameters - the notebook workspace to create for the current database account. +func (client NotebookWorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (result NotebookWorkspacesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, notebookCreateUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotebookWorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithJSON(notebookCreateUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) CreateOrUpdateSender(req *http.Request) (future NotebookWorkspacesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotebookWorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", 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 NotebookWorkspacesClient) DeleteSender(req *http.Request) (future NotebookWorkspacesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotebookWorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) GetResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount gets the notebook workspace resources of an existing Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure responding to request") + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client NotebookWorkspacesClient) ListByDatabaseAccountPreparer(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 = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListByDatabaseAccountResponder(resp *http.Response) (result NotebookWorkspaceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListConnectionInfo retrieves the connection info for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceConnectionInfoResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListConnectionInfo") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListConnectionInfo", err.Error()) + } + + req, err := client.ListConnectionInfoPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure responding to request") + } + + return +} + +// ListConnectionInfoPreparer prepares the ListConnectionInfo request. +func (client NotebookWorkspacesClient) ListConnectionInfoPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionInfoSender sends the ListConnectionInfo request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListConnectionInfoSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionInfoResponder handles the response to the ListConnectionInfo request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListConnectionInfoResponder(resp *http.Response) (result NotebookWorkspaceConnectionInfoResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateAuthToken regenerates the auth token for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.RegenerateAuthToken") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", err.Error()) + } + + req, err := client.RegenerateAuthTokenPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateAuthTokenSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", result.Response(), "Failure sending request") + return + } + + return +} + +// RegenerateAuthTokenPreparer prepares the RegenerateAuthToken request. +func (client NotebookWorkspacesClient) RegenerateAuthTokenPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateAuthTokenSender sends the RegenerateAuthToken request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) RegenerateAuthTokenSender(req *http.Request) (future NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RegenerateAuthTokenResponder handles the response to the RegenerateAuthToken request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) RegenerateAuthTokenResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Start(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Start") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", result.Response(), "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client NotebookWorkspacesClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) StartSender(req *http.Request) (future NotebookWorkspacesStartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/privatelinkresources.go b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/privatelinkresources.go index a13e3bddebd2..215288ea9a8e 100644 --- a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/privatelinkresources.go +++ b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/privatelinkresources.go @@ -45,7 +45,7 @@ func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID str // Get gets the private link resources that need to be created for a Cosmos DB account. // Parameters: -// resourceGroupName - name of an Azure resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // accountName - cosmos DB database account name. // groupName - the name of the private link resource. func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result PrivateLinkResource, err error) { @@ -60,6 +60,8 @@ func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupN }() } if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, @@ -135,7 +137,7 @@ func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (resu // ListByDatabaseAccount gets the private link resources that need to be created for a Cosmos DB account. // Parameters: -// resourceGroupName - name of an Azure resource group. +// resourceGroupName - the name of the resource group. The name is case insensitive. // accountName - cosmos DB database account name. func (client PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListResult, err error) { if tracing.IsEnabled() { @@ -149,6 +151,8 @@ func (client PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Conte }() } if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, diff --git a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/version.go b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/version.go index 2906624d5ee2..35d48120ff12 100644 --- a/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/version.go +++ b/services/preview/cosmos-db/mgmt/2019-08-01-preview/documentdb/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " documentdb/2019-08-01-preview" + return "Azure-SDK-For-Go/" + Version() + " documentdb/2019-08-01-preview" } // Version returns the semantic version (see http://semver.org) of the client.