...

Source file src/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2022-08-15/documentdb/notebookworkspaces.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2022-08-15/documentdb

     1  package documentdb
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // NotebookWorkspacesClient is the client for the NotebookWorkspaces methods of the Documentdb service.
    19  type NotebookWorkspacesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewNotebookWorkspacesClient creates an instance of the NotebookWorkspacesClient client.
    24  func NewNotebookWorkspacesClient(subscriptionID string) NotebookWorkspacesClient {
    25  	return NewNotebookWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewNotebookWorkspacesClientWithBaseURI creates an instance of the NotebookWorkspacesClient client using a custom
    29  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    30  // stack).
    31  func NewNotebookWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) NotebookWorkspacesClient {
    32  	return NotebookWorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates the notebook workspace for a Cosmos DB account.
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group. The name is case insensitive.
    38  // accountName - cosmos DB database account name.
    39  // notebookCreateUpdateParameters - the notebook workspace to create for the current database account.
    40  func (client NotebookWorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (result NotebookWorkspacesCreateOrUpdateFuture, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.CreateOrUpdate")
    43  		defer func() {
    44  			sc := -1
    45  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    46  				sc = result.FutureAPI.Response().StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	if err := validation.Validate([]validation.Validation{
    52  		{TargetValue: client.SubscriptionID,
    53  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    54  		{TargetValue: resourceGroupName,
    55  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    57  		{TargetValue: accountName,
    58  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    59  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
    60  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
    61  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "CreateOrUpdate", err.Error())
    62  	}
    63  
    64  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, notebookCreateUpdateParameters)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request")
    67  		return
    68  	}
    69  
    70  	result, err = client.CreateOrUpdateSender(req)
    71  	if err != nil {
    72  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    73  		return
    74  	}
    75  
    76  	return
    77  }
    78  
    79  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    80  func (client NotebookWorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (*http.Request, error) {
    81  	pathParameters := map[string]interface{}{
    82  		"accountName":           autorest.Encode("path", accountName),
    83  		"notebookWorkspaceName": autorest.Encode("path", "default"),
    84  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
    85  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
    86  	}
    87  
    88  	const APIVersion = "2022-08-15"
    89  	queryParameters := map[string]interface{}{
    90  		"api-version": APIVersion,
    91  	}
    92  
    93  	preparer := autorest.CreatePreparer(
    94  		autorest.AsContentType("application/json; charset=utf-8"),
    95  		autorest.AsPut(),
    96  		autorest.WithBaseURL(client.BaseURI),
    97  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters),
    98  		autorest.WithJSON(notebookCreateUpdateParameters),
    99  		autorest.WithQueryParameters(queryParameters))
   100  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   101  }
   102  
   103  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   104  // http.Response Body if it receives an error.
   105  func (client NotebookWorkspacesClient) CreateOrUpdateSender(req *http.Request) (future NotebookWorkspacesCreateOrUpdateFuture, err error) {
   106  	var resp *http.Response
   107  	future.FutureAPI = &azure.Future{}
   108  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   109  	if err != nil {
   110  		return
   111  	}
   112  	var azf azure.Future
   113  	azf, err = azure.NewFutureFromResponse(resp)
   114  	future.FutureAPI = &azf
   115  	future.Result = future.result
   116  	return
   117  }
   118  
   119  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   120  // closes the http.Response Body.
   121  func (client NotebookWorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result NotebookWorkspace, err error) {
   122  	err = autorest.Respond(
   123  		resp,
   124  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   125  		autorest.ByUnmarshallingJSON(&result),
   126  		autorest.ByClosing())
   127  	result.Response = autorest.Response{Response: resp}
   128  	return
   129  }
   130  
   131  // Delete deletes the notebook workspace for a Cosmos DB account.
   132  // Parameters:
   133  // resourceGroupName - the name of the resource group. The name is case insensitive.
   134  // accountName - cosmos DB database account name.
   135  func (client NotebookWorkspacesClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesDeleteFuture, err error) {
   136  	if tracing.IsEnabled() {
   137  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Delete")
   138  		defer func() {
   139  			sc := -1
   140  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   141  				sc = result.FutureAPI.Response().StatusCode
   142  			}
   143  			tracing.EndSpan(ctx, sc, err)
   144  		}()
   145  	}
   146  	if err := validation.Validate([]validation.Validation{
   147  		{TargetValue: client.SubscriptionID,
   148  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   149  		{TargetValue: resourceGroupName,
   150  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   151  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   152  		{TargetValue: accountName,
   153  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   154  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   155  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   156  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Delete", err.Error())
   157  	}
   158  
   159  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure preparing request")
   162  		return
   163  	}
   164  
   165  	result, err = client.DeleteSender(req)
   166  	if err != nil {
   167  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", result.Response(), "Failure sending request")
   168  		return
   169  	}
   170  
   171  	return
   172  }
   173  
   174  // DeletePreparer prepares the Delete request.
   175  func (client NotebookWorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   176  	pathParameters := map[string]interface{}{
   177  		"accountName":           autorest.Encode("path", accountName),
   178  		"notebookWorkspaceName": autorest.Encode("path", "default"),
   179  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
   180  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
   181  	}
   182  
   183  	const APIVersion = "2022-08-15"
   184  	queryParameters := map[string]interface{}{
   185  		"api-version": APIVersion,
   186  	}
   187  
   188  	preparer := autorest.CreatePreparer(
   189  		autorest.AsDelete(),
   190  		autorest.WithBaseURL(client.BaseURI),
   191  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters),
   192  		autorest.WithQueryParameters(queryParameters))
   193  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   194  }
   195  
   196  // DeleteSender sends the Delete request. The method will close the
   197  // http.Response Body if it receives an error.
   198  func (client NotebookWorkspacesClient) DeleteSender(req *http.Request) (future NotebookWorkspacesDeleteFuture, err error) {
   199  	var resp *http.Response
   200  	future.FutureAPI = &azure.Future{}
   201  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   202  	if err != nil {
   203  		return
   204  	}
   205  	var azf azure.Future
   206  	azf, err = azure.NewFutureFromResponse(resp)
   207  	future.FutureAPI = &azf
   208  	future.Result = future.result
   209  	return
   210  }
   211  
   212  // DeleteResponder handles the response to the Delete request. The method always
   213  // closes the http.Response Body.
   214  func (client NotebookWorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   215  	err = autorest.Respond(
   216  		resp,
   217  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   218  		autorest.ByClosing())
   219  	result.Response = resp
   220  	return
   221  }
   222  
   223  // Get gets the notebook workspace for a Cosmos DB account.
   224  // Parameters:
   225  // resourceGroupName - the name of the resource group. The name is case insensitive.
   226  // accountName - cosmos DB database account name.
   227  func (client NotebookWorkspacesClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspace, err error) {
   228  	if tracing.IsEnabled() {
   229  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Get")
   230  		defer func() {
   231  			sc := -1
   232  			if result.Response.Response != nil {
   233  				sc = result.Response.Response.StatusCode
   234  			}
   235  			tracing.EndSpan(ctx, sc, err)
   236  		}()
   237  	}
   238  	if err := validation.Validate([]validation.Validation{
   239  		{TargetValue: client.SubscriptionID,
   240  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   241  		{TargetValue: resourceGroupName,
   242  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   243  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   244  		{TargetValue: accountName,
   245  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   246  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   247  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   248  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Get", err.Error())
   249  	}
   250  
   251  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName)
   252  	if err != nil {
   253  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", nil, "Failure preparing request")
   254  		return
   255  	}
   256  
   257  	resp, err := client.GetSender(req)
   258  	if err != nil {
   259  		result.Response = autorest.Response{Response: resp}
   260  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure sending request")
   261  		return
   262  	}
   263  
   264  	result, err = client.GetResponder(resp)
   265  	if err != nil {
   266  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure responding to request")
   267  		return
   268  	}
   269  
   270  	return
   271  }
   272  
   273  // GetPreparer prepares the Get request.
   274  func (client NotebookWorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   275  	pathParameters := map[string]interface{}{
   276  		"accountName":           autorest.Encode("path", accountName),
   277  		"notebookWorkspaceName": autorest.Encode("path", "default"),
   278  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
   279  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
   280  	}
   281  
   282  	const APIVersion = "2022-08-15"
   283  	queryParameters := map[string]interface{}{
   284  		"api-version": APIVersion,
   285  	}
   286  
   287  	preparer := autorest.CreatePreparer(
   288  		autorest.AsGet(),
   289  		autorest.WithBaseURL(client.BaseURI),
   290  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters),
   291  		autorest.WithQueryParameters(queryParameters))
   292  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   293  }
   294  
   295  // GetSender sends the Get request. The method will close the
   296  // http.Response Body if it receives an error.
   297  func (client NotebookWorkspacesClient) GetSender(req *http.Request) (*http.Response, error) {
   298  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   299  }
   300  
   301  // GetResponder handles the response to the Get request. The method always
   302  // closes the http.Response Body.
   303  func (client NotebookWorkspacesClient) GetResponder(resp *http.Response) (result NotebookWorkspace, err error) {
   304  	err = autorest.Respond(
   305  		resp,
   306  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   307  		autorest.ByUnmarshallingJSON(&result),
   308  		autorest.ByClosing())
   309  	result.Response = autorest.Response{Response: resp}
   310  	return
   311  }
   312  
   313  // ListByDatabaseAccount gets the notebook workspace resources of an existing Cosmos DB account.
   314  // Parameters:
   315  // resourceGroupName - the name of the resource group. The name is case insensitive.
   316  // accountName - cosmos DB database account name.
   317  func (client NotebookWorkspacesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceListResult, err error) {
   318  	if tracing.IsEnabled() {
   319  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListByDatabaseAccount")
   320  		defer func() {
   321  			sc := -1
   322  			if result.Response.Response != nil {
   323  				sc = result.Response.Response.StatusCode
   324  			}
   325  			tracing.EndSpan(ctx, sc, err)
   326  		}()
   327  	}
   328  	if err := validation.Validate([]validation.Validation{
   329  		{TargetValue: client.SubscriptionID,
   330  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   331  		{TargetValue: resourceGroupName,
   332  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   333  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   334  		{TargetValue: accountName,
   335  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   336  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   337  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   338  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", err.Error())
   339  	}
   340  
   341  	req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName)
   342  	if err != nil {
   343  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", nil, "Failure preparing request")
   344  		return
   345  	}
   346  
   347  	resp, err := client.ListByDatabaseAccountSender(req)
   348  	if err != nil {
   349  		result.Response = autorest.Response{Response: resp}
   350  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure sending request")
   351  		return
   352  	}
   353  
   354  	result, err = client.ListByDatabaseAccountResponder(resp)
   355  	if err != nil {
   356  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure responding to request")
   357  		return
   358  	}
   359  
   360  	return
   361  }
   362  
   363  // ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request.
   364  func (client NotebookWorkspacesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   365  	pathParameters := map[string]interface{}{
   366  		"accountName":       autorest.Encode("path", accountName),
   367  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   368  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   369  	}
   370  
   371  	const APIVersion = "2022-08-15"
   372  	queryParameters := map[string]interface{}{
   373  		"api-version": APIVersion,
   374  	}
   375  
   376  	preparer := autorest.CreatePreparer(
   377  		autorest.AsGet(),
   378  		autorest.WithBaseURL(client.BaseURI),
   379  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", pathParameters),
   380  		autorest.WithQueryParameters(queryParameters))
   381  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   382  }
   383  
   384  // ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the
   385  // http.Response Body if it receives an error.
   386  func (client NotebookWorkspacesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) {
   387  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   388  }
   389  
   390  // ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always
   391  // closes the http.Response Body.
   392  func (client NotebookWorkspacesClient) ListByDatabaseAccountResponder(resp *http.Response) (result NotebookWorkspaceListResult, err error) {
   393  	err = autorest.Respond(
   394  		resp,
   395  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   396  		autorest.ByUnmarshallingJSON(&result),
   397  		autorest.ByClosing())
   398  	result.Response = autorest.Response{Response: resp}
   399  	return
   400  }
   401  
   402  // ListConnectionInfo retrieves the connection info for the notebook workspace
   403  // Parameters:
   404  // resourceGroupName - the name of the resource group. The name is case insensitive.
   405  // accountName - cosmos DB database account name.
   406  func (client NotebookWorkspacesClient) ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceConnectionInfoResult, err error) {
   407  	if tracing.IsEnabled() {
   408  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListConnectionInfo")
   409  		defer func() {
   410  			sc := -1
   411  			if result.Response.Response != nil {
   412  				sc = result.Response.Response.StatusCode
   413  			}
   414  			tracing.EndSpan(ctx, sc, err)
   415  		}()
   416  	}
   417  	if err := validation.Validate([]validation.Validation{
   418  		{TargetValue: client.SubscriptionID,
   419  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   420  		{TargetValue: resourceGroupName,
   421  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   422  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   423  		{TargetValue: accountName,
   424  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   425  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   426  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   427  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListConnectionInfo", err.Error())
   428  	}
   429  
   430  	req, err := client.ListConnectionInfoPreparer(ctx, resourceGroupName, accountName)
   431  	if err != nil {
   432  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", nil, "Failure preparing request")
   433  		return
   434  	}
   435  
   436  	resp, err := client.ListConnectionInfoSender(req)
   437  	if err != nil {
   438  		result.Response = autorest.Response{Response: resp}
   439  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure sending request")
   440  		return
   441  	}
   442  
   443  	result, err = client.ListConnectionInfoResponder(resp)
   444  	if err != nil {
   445  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure responding to request")
   446  		return
   447  	}
   448  
   449  	return
   450  }
   451  
   452  // ListConnectionInfoPreparer prepares the ListConnectionInfo request.
   453  func (client NotebookWorkspacesClient) ListConnectionInfoPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   454  	pathParameters := map[string]interface{}{
   455  		"accountName":           autorest.Encode("path", accountName),
   456  		"notebookWorkspaceName": autorest.Encode("path", "default"),
   457  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
   458  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
   459  	}
   460  
   461  	const APIVersion = "2022-08-15"
   462  	queryParameters := map[string]interface{}{
   463  		"api-version": APIVersion,
   464  	}
   465  
   466  	preparer := autorest.CreatePreparer(
   467  		autorest.AsPost(),
   468  		autorest.WithBaseURL(client.BaseURI),
   469  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", pathParameters),
   470  		autorest.WithQueryParameters(queryParameters))
   471  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   472  }
   473  
   474  // ListConnectionInfoSender sends the ListConnectionInfo request. The method will close the
   475  // http.Response Body if it receives an error.
   476  func (client NotebookWorkspacesClient) ListConnectionInfoSender(req *http.Request) (*http.Response, error) {
   477  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   478  }
   479  
   480  // ListConnectionInfoResponder handles the response to the ListConnectionInfo request. The method always
   481  // closes the http.Response Body.
   482  func (client NotebookWorkspacesClient) ListConnectionInfoResponder(resp *http.Response) (result NotebookWorkspaceConnectionInfoResult, err error) {
   483  	err = autorest.Respond(
   484  		resp,
   485  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   486  		autorest.ByUnmarshallingJSON(&result),
   487  		autorest.ByClosing())
   488  	result.Response = autorest.Response{Response: resp}
   489  	return
   490  }
   491  
   492  // RegenerateAuthToken regenerates the auth token for the notebook workspace
   493  // Parameters:
   494  // resourceGroupName - the name of the resource group. The name is case insensitive.
   495  // accountName - cosmos DB database account name.
   496  func (client NotebookWorkspacesClient) RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesRegenerateAuthTokenFuture, err error) {
   497  	if tracing.IsEnabled() {
   498  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.RegenerateAuthToken")
   499  		defer func() {
   500  			sc := -1
   501  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   502  				sc = result.FutureAPI.Response().StatusCode
   503  			}
   504  			tracing.EndSpan(ctx, sc, err)
   505  		}()
   506  	}
   507  	if err := validation.Validate([]validation.Validation{
   508  		{TargetValue: client.SubscriptionID,
   509  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   510  		{TargetValue: resourceGroupName,
   511  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   512  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   513  		{TargetValue: accountName,
   514  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   515  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   516  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   517  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", err.Error())
   518  	}
   519  
   520  	req, err := client.RegenerateAuthTokenPreparer(ctx, resourceGroupName, accountName)
   521  	if err != nil {
   522  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure preparing request")
   523  		return
   524  	}
   525  
   526  	result, err = client.RegenerateAuthTokenSender(req)
   527  	if err != nil {
   528  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", result.Response(), "Failure sending request")
   529  		return
   530  	}
   531  
   532  	return
   533  }
   534  
   535  // RegenerateAuthTokenPreparer prepares the RegenerateAuthToken request.
   536  func (client NotebookWorkspacesClient) RegenerateAuthTokenPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   537  	pathParameters := map[string]interface{}{
   538  		"accountName":           autorest.Encode("path", accountName),
   539  		"notebookWorkspaceName": autorest.Encode("path", "default"),
   540  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
   541  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
   542  	}
   543  
   544  	const APIVersion = "2022-08-15"
   545  	queryParameters := map[string]interface{}{
   546  		"api-version": APIVersion,
   547  	}
   548  
   549  	preparer := autorest.CreatePreparer(
   550  		autorest.AsPost(),
   551  		autorest.WithBaseURL(client.BaseURI),
   552  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", pathParameters),
   553  		autorest.WithQueryParameters(queryParameters))
   554  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   555  }
   556  
   557  // RegenerateAuthTokenSender sends the RegenerateAuthToken request. The method will close the
   558  // http.Response Body if it receives an error.
   559  func (client NotebookWorkspacesClient) RegenerateAuthTokenSender(req *http.Request) (future NotebookWorkspacesRegenerateAuthTokenFuture, err error) {
   560  	var resp *http.Response
   561  	future.FutureAPI = &azure.Future{}
   562  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   563  	if err != nil {
   564  		return
   565  	}
   566  	var azf azure.Future
   567  	azf, err = azure.NewFutureFromResponse(resp)
   568  	future.FutureAPI = &azf
   569  	future.Result = future.result
   570  	return
   571  }
   572  
   573  // RegenerateAuthTokenResponder handles the response to the RegenerateAuthToken request. The method always
   574  // closes the http.Response Body.
   575  func (client NotebookWorkspacesClient) RegenerateAuthTokenResponder(resp *http.Response) (result autorest.Response, err error) {
   576  	err = autorest.Respond(
   577  		resp,
   578  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   579  		autorest.ByClosing())
   580  	result.Response = resp
   581  	return
   582  }
   583  
   584  // Start starts the notebook workspace
   585  // Parameters:
   586  // resourceGroupName - the name of the resource group. The name is case insensitive.
   587  // accountName - cosmos DB database account name.
   588  func (client NotebookWorkspacesClient) Start(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesStartFuture, err error) {
   589  	if tracing.IsEnabled() {
   590  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Start")
   591  		defer func() {
   592  			sc := -1
   593  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   594  				sc = result.FutureAPI.Response().StatusCode
   595  			}
   596  			tracing.EndSpan(ctx, sc, err)
   597  		}()
   598  	}
   599  	if err := validation.Validate([]validation.Validation{
   600  		{TargetValue: client.SubscriptionID,
   601  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   602  		{TargetValue: resourceGroupName,
   603  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   604  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   605  		{TargetValue: accountName,
   606  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   607  				{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
   608  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil {
   609  		return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Start", err.Error())
   610  	}
   611  
   612  	req, err := client.StartPreparer(ctx, resourceGroupName, accountName)
   613  	if err != nil {
   614  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure preparing request")
   615  		return
   616  	}
   617  
   618  	result, err = client.StartSender(req)
   619  	if err != nil {
   620  		err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", result.Response(), "Failure sending request")
   621  		return
   622  	}
   623  
   624  	return
   625  }
   626  
   627  // StartPreparer prepares the Start request.
   628  func (client NotebookWorkspacesClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   629  	pathParameters := map[string]interface{}{
   630  		"accountName":           autorest.Encode("path", accountName),
   631  		"notebookWorkspaceName": autorest.Encode("path", "default"),
   632  		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
   633  		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
   634  	}
   635  
   636  	const APIVersion = "2022-08-15"
   637  	queryParameters := map[string]interface{}{
   638  		"api-version": APIVersion,
   639  	}
   640  
   641  	preparer := autorest.CreatePreparer(
   642  		autorest.AsPost(),
   643  		autorest.WithBaseURL(client.BaseURI),
   644  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", pathParameters),
   645  		autorest.WithQueryParameters(queryParameters))
   646  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   647  }
   648  
   649  // StartSender sends the Start request. The method will close the
   650  // http.Response Body if it receives an error.
   651  func (client NotebookWorkspacesClient) StartSender(req *http.Request) (future NotebookWorkspacesStartFuture, err error) {
   652  	var resp *http.Response
   653  	future.FutureAPI = &azure.Future{}
   654  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   655  	if err != nil {
   656  		return
   657  	}
   658  	var azf azure.Future
   659  	azf, err = azure.NewFutureFromResponse(resp)
   660  	future.FutureAPI = &azf
   661  	future.Result = future.result
   662  	return
   663  }
   664  
   665  // StartResponder handles the response to the Start request. The method always
   666  // closes the http.Response Body.
   667  func (client NotebookWorkspacesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
   668  	err = autorest.Respond(
   669  		resp,
   670  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   671  		autorest.ByClosing())
   672  	result.Response = resp
   673  	return
   674  }
   675  

View as plain text