...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts/notebook.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts

     1  package artifacts
     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  // NotebookClient is the client for the Notebook methods of the Artifacts service.
    19  type NotebookClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewNotebookClient creates an instance of the NotebookClient client.
    24  func NewNotebookClient(endpoint string) NotebookClient {
    25  	return NotebookClient{New(endpoint)}
    26  }
    27  
    28  // CreateOrUpdateNotebook creates or updates a Note Book.
    29  // Parameters:
    30  // notebookName - the notebook name.
    31  // notebook - note book resource definition.
    32  // ifMatch - eTag of the Note book entity.  Should only be specified for update, for which it should match
    33  // existing entity or can be * for unconditional update.
    34  func (client NotebookClient) CreateOrUpdateNotebook(ctx context.Context, notebookName string, notebook NotebookResource, ifMatch string) (result NotebookCreateOrUpdateNotebookFuture, err error) {
    35  	if tracing.IsEnabled() {
    36  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.CreateOrUpdateNotebook")
    37  		defer func() {
    38  			sc := -1
    39  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    40  				sc = result.FutureAPI.Response().StatusCode
    41  			}
    42  			tracing.EndSpan(ctx, sc, err)
    43  		}()
    44  	}
    45  	if err := validation.Validate([]validation.Validation{
    46  		{TargetValue: notebook,
    47  			Constraints: []validation.Constraint{{Target: "notebook.Name", Name: validation.Null, Rule: true, Chain: nil},
    48  				{Target: "notebook.Properties", Name: validation.Null, Rule: true,
    49  					Chain: []validation.Constraint{{Target: "notebook.Properties.BigDataPool", Name: validation.Null, Rule: false,
    50  						Chain: []validation.Constraint{{Target: "notebook.Properties.BigDataPool.Type", Name: validation.Null, Rule: true, Chain: nil},
    51  							{Target: "notebook.Properties.BigDataPool.ReferenceName", Name: validation.Null, Rule: true, Chain: nil},
    52  						}},
    53  						{Target: "notebook.Properties.SessionProperties", Name: validation.Null, Rule: false,
    54  							Chain: []validation.Constraint{{Target: "notebook.Properties.SessionProperties.DriverMemory", Name: validation.Null, Rule: true, Chain: nil},
    55  								{Target: "notebook.Properties.SessionProperties.DriverCores", Name: validation.Null, Rule: true, Chain: nil},
    56  								{Target: "notebook.Properties.SessionProperties.ExecutorMemory", Name: validation.Null, Rule: true, Chain: nil},
    57  								{Target: "notebook.Properties.SessionProperties.ExecutorCores", Name: validation.Null, Rule: true, Chain: nil},
    58  								{Target: "notebook.Properties.SessionProperties.NumExecutors", Name: validation.Null, Rule: true, Chain: nil},
    59  							}},
    60  						{Target: "notebook.Properties.Metadata", Name: validation.Null, Rule: true,
    61  							Chain: []validation.Constraint{{Target: "notebook.Properties.Metadata.Kernelspec", Name: validation.Null, Rule: false,
    62  								Chain: []validation.Constraint{{Target: "notebook.Properties.Metadata.Kernelspec.Name", Name: validation.Null, Rule: true, Chain: nil},
    63  									{Target: "notebook.Properties.Metadata.Kernelspec.DisplayName", Name: validation.Null, Rule: true, Chain: nil},
    64  								}},
    65  								{Target: "notebook.Properties.Metadata.LanguageInfo", Name: validation.Null, Rule: false,
    66  									Chain: []validation.Constraint{{Target: "notebook.Properties.Metadata.LanguageInfo.Name", Name: validation.Null, Rule: true, Chain: nil}}},
    67  							}},
    68  						{Target: "notebook.Properties.Nbformat", Name: validation.Null, Rule: true, Chain: nil},
    69  						{Target: "notebook.Properties.NbformatMinor", Name: validation.Null, Rule: true, Chain: nil},
    70  						{Target: "notebook.Properties.Cells", Name: validation.Null, Rule: true, Chain: nil},
    71  					}}}}}); err != nil {
    72  		return result, validation.NewError("artifacts.NotebookClient", "CreateOrUpdateNotebook", err.Error())
    73  	}
    74  
    75  	req, err := client.CreateOrUpdateNotebookPreparer(ctx, notebookName, notebook, ifMatch)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "CreateOrUpdateNotebook", nil, "Failure preparing request")
    78  		return
    79  	}
    80  
    81  	result, err = client.CreateOrUpdateNotebookSender(req)
    82  	if err != nil {
    83  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "CreateOrUpdateNotebook", nil, "Failure sending request")
    84  		return
    85  	}
    86  
    87  	return
    88  }
    89  
    90  // CreateOrUpdateNotebookPreparer prepares the CreateOrUpdateNotebook request.
    91  func (client NotebookClient) CreateOrUpdateNotebookPreparer(ctx context.Context, notebookName string, notebook NotebookResource, ifMatch string) (*http.Request, error) {
    92  	urlParameters := map[string]interface{}{
    93  		"endpoint": client.Endpoint,
    94  	}
    95  
    96  	pathParameters := map[string]interface{}{
    97  		"notebookName": autorest.Encode("path", notebookName),
    98  	}
    99  
   100  	const APIVersion = "2019-06-01-preview"
   101  	queryParameters := map[string]interface{}{
   102  		"api-version": APIVersion,
   103  	}
   104  
   105  	notebook.ID = nil
   106  	notebook.Type = nil
   107  	notebook.Etag = nil
   108  	preparer := autorest.CreatePreparer(
   109  		autorest.AsContentType("application/json; charset=utf-8"),
   110  		autorest.AsPut(),
   111  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   112  		autorest.WithPathParameters("/notebooks/{notebookName}", pathParameters),
   113  		autorest.WithJSON(notebook),
   114  		autorest.WithQueryParameters(queryParameters))
   115  	if len(ifMatch) > 0 {
   116  		preparer = autorest.DecoratePreparer(preparer,
   117  			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
   118  	}
   119  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   120  }
   121  
   122  // CreateOrUpdateNotebookSender sends the CreateOrUpdateNotebook request. The method will close the
   123  // http.Response Body if it receives an error.
   124  func (client NotebookClient) CreateOrUpdateNotebookSender(req *http.Request) (future NotebookCreateOrUpdateNotebookFuture, err error) {
   125  	var resp *http.Response
   126  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   127  	if err != nil {
   128  		return
   129  	}
   130  	var azf azure.Future
   131  	azf, err = azure.NewFutureFromResponse(resp)
   132  	future.FutureAPI = &azf
   133  	future.Result = future.result
   134  	return
   135  }
   136  
   137  // CreateOrUpdateNotebookResponder handles the response to the CreateOrUpdateNotebook request. The method always
   138  // closes the http.Response Body.
   139  func (client NotebookClient) CreateOrUpdateNotebookResponder(resp *http.Response) (result NotebookResource, err error) {
   140  	err = autorest.Respond(
   141  		resp,
   142  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   143  		autorest.ByUnmarshallingJSON(&result),
   144  		autorest.ByClosing())
   145  	result.Response = autorest.Response{Response: resp}
   146  	return
   147  }
   148  
   149  // DeleteNotebook deletes a Note book.
   150  // Parameters:
   151  // notebookName - the notebook name.
   152  func (client NotebookClient) DeleteNotebook(ctx context.Context, notebookName string) (result NotebookDeleteNotebookFuture, err error) {
   153  	if tracing.IsEnabled() {
   154  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.DeleteNotebook")
   155  		defer func() {
   156  			sc := -1
   157  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   158  				sc = result.FutureAPI.Response().StatusCode
   159  			}
   160  			tracing.EndSpan(ctx, sc, err)
   161  		}()
   162  	}
   163  	req, err := client.DeleteNotebookPreparer(ctx, notebookName)
   164  	if err != nil {
   165  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "DeleteNotebook", nil, "Failure preparing request")
   166  		return
   167  	}
   168  
   169  	result, err = client.DeleteNotebookSender(req)
   170  	if err != nil {
   171  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "DeleteNotebook", nil, "Failure sending request")
   172  		return
   173  	}
   174  
   175  	return
   176  }
   177  
   178  // DeleteNotebookPreparer prepares the DeleteNotebook request.
   179  func (client NotebookClient) DeleteNotebookPreparer(ctx context.Context, notebookName string) (*http.Request, error) {
   180  	urlParameters := map[string]interface{}{
   181  		"endpoint": client.Endpoint,
   182  	}
   183  
   184  	pathParameters := map[string]interface{}{
   185  		"notebookName": autorest.Encode("path", notebookName),
   186  	}
   187  
   188  	const APIVersion = "2019-06-01-preview"
   189  	queryParameters := map[string]interface{}{
   190  		"api-version": APIVersion,
   191  	}
   192  
   193  	preparer := autorest.CreatePreparer(
   194  		autorest.AsDelete(),
   195  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   196  		autorest.WithPathParameters("/notebooks/{notebookName}", pathParameters),
   197  		autorest.WithQueryParameters(queryParameters))
   198  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   199  }
   200  
   201  // DeleteNotebookSender sends the DeleteNotebook request. The method will close the
   202  // http.Response Body if it receives an error.
   203  func (client NotebookClient) DeleteNotebookSender(req *http.Request) (future NotebookDeleteNotebookFuture, err error) {
   204  	var resp *http.Response
   205  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   206  	if err != nil {
   207  		return
   208  	}
   209  	var azf azure.Future
   210  	azf, err = azure.NewFutureFromResponse(resp)
   211  	future.FutureAPI = &azf
   212  	future.Result = future.result
   213  	return
   214  }
   215  
   216  // DeleteNotebookResponder handles the response to the DeleteNotebook request. The method always
   217  // closes the http.Response Body.
   218  func (client NotebookClient) DeleteNotebookResponder(resp *http.Response) (result autorest.Response, err error) {
   219  	err = autorest.Respond(
   220  		resp,
   221  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   222  		autorest.ByClosing())
   223  	result.Response = resp
   224  	return
   225  }
   226  
   227  // GetNotebook gets a Note Book.
   228  // Parameters:
   229  // notebookName - the notebook name.
   230  // ifNoneMatch - eTag of the Notebook entity. Should only be specified for get. If the ETag matches the
   231  // existing entity tag, or if * was provided, then no content will be returned.
   232  func (client NotebookClient) GetNotebook(ctx context.Context, notebookName string, ifNoneMatch string) (result NotebookResource, err error) {
   233  	if tracing.IsEnabled() {
   234  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.GetNotebook")
   235  		defer func() {
   236  			sc := -1
   237  			if result.Response.Response != nil {
   238  				sc = result.Response.Response.StatusCode
   239  			}
   240  			tracing.EndSpan(ctx, sc, err)
   241  		}()
   242  	}
   243  	req, err := client.GetNotebookPreparer(ctx, notebookName, ifNoneMatch)
   244  	if err != nil {
   245  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebook", nil, "Failure preparing request")
   246  		return
   247  	}
   248  
   249  	resp, err := client.GetNotebookSender(req)
   250  	if err != nil {
   251  		result.Response = autorest.Response{Response: resp}
   252  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebook", resp, "Failure sending request")
   253  		return
   254  	}
   255  
   256  	result, err = client.GetNotebookResponder(resp)
   257  	if err != nil {
   258  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebook", resp, "Failure responding to request")
   259  		return
   260  	}
   261  
   262  	return
   263  }
   264  
   265  // GetNotebookPreparer prepares the GetNotebook request.
   266  func (client NotebookClient) GetNotebookPreparer(ctx context.Context, notebookName string, ifNoneMatch string) (*http.Request, error) {
   267  	urlParameters := map[string]interface{}{
   268  		"endpoint": client.Endpoint,
   269  	}
   270  
   271  	pathParameters := map[string]interface{}{
   272  		"notebookName": autorest.Encode("path", notebookName),
   273  	}
   274  
   275  	const APIVersion = "2019-06-01-preview"
   276  	queryParameters := map[string]interface{}{
   277  		"api-version": APIVersion,
   278  	}
   279  
   280  	preparer := autorest.CreatePreparer(
   281  		autorest.AsGet(),
   282  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   283  		autorest.WithPathParameters("/notebooks/{notebookName}", pathParameters),
   284  		autorest.WithQueryParameters(queryParameters))
   285  	if len(ifNoneMatch) > 0 {
   286  		preparer = autorest.DecoratePreparer(preparer,
   287  			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
   288  	}
   289  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   290  }
   291  
   292  // GetNotebookSender sends the GetNotebook request. The method will close the
   293  // http.Response Body if it receives an error.
   294  func (client NotebookClient) GetNotebookSender(req *http.Request) (*http.Response, error) {
   295  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   296  }
   297  
   298  // GetNotebookResponder handles the response to the GetNotebook request. The method always
   299  // closes the http.Response Body.
   300  func (client NotebookClient) GetNotebookResponder(resp *http.Response) (result NotebookResource, err error) {
   301  	err = autorest.Respond(
   302  		resp,
   303  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotModified),
   304  		autorest.ByUnmarshallingJSON(&result),
   305  		autorest.ByClosing())
   306  	result.Response = autorest.Response{Response: resp}
   307  	return
   308  }
   309  
   310  // GetNotebooksByWorkspace lists Notebooks.
   311  func (client NotebookClient) GetNotebooksByWorkspace(ctx context.Context) (result NotebookListResponsePage, err error) {
   312  	if tracing.IsEnabled() {
   313  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.GetNotebooksByWorkspace")
   314  		defer func() {
   315  			sc := -1
   316  			if result.nlr.Response.Response != nil {
   317  				sc = result.nlr.Response.Response.StatusCode
   318  			}
   319  			tracing.EndSpan(ctx, sc, err)
   320  		}()
   321  	}
   322  	result.fn = client.getNotebooksByWorkspaceNextResults
   323  	req, err := client.GetNotebooksByWorkspacePreparer(ctx)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebooksByWorkspace", nil, "Failure preparing request")
   326  		return
   327  	}
   328  
   329  	resp, err := client.GetNotebooksByWorkspaceSender(req)
   330  	if err != nil {
   331  		result.nlr.Response = autorest.Response{Response: resp}
   332  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebooksByWorkspace", resp, "Failure sending request")
   333  		return
   334  	}
   335  
   336  	result.nlr, err = client.GetNotebooksByWorkspaceResponder(resp)
   337  	if err != nil {
   338  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebooksByWorkspace", resp, "Failure responding to request")
   339  		return
   340  	}
   341  	if result.nlr.hasNextLink() && result.nlr.IsEmpty() {
   342  		err = result.NextWithContext(ctx)
   343  		return
   344  	}
   345  
   346  	return
   347  }
   348  
   349  // GetNotebooksByWorkspacePreparer prepares the GetNotebooksByWorkspace request.
   350  func (client NotebookClient) GetNotebooksByWorkspacePreparer(ctx context.Context) (*http.Request, error) {
   351  	urlParameters := map[string]interface{}{
   352  		"endpoint": client.Endpoint,
   353  	}
   354  
   355  	const APIVersion = "2019-06-01-preview"
   356  	queryParameters := map[string]interface{}{
   357  		"api-version": APIVersion,
   358  	}
   359  
   360  	preparer := autorest.CreatePreparer(
   361  		autorest.AsGet(),
   362  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   363  		autorest.WithPath("/notebooks"),
   364  		autorest.WithQueryParameters(queryParameters))
   365  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   366  }
   367  
   368  // GetNotebooksByWorkspaceSender sends the GetNotebooksByWorkspace request. The method will close the
   369  // http.Response Body if it receives an error.
   370  func (client NotebookClient) GetNotebooksByWorkspaceSender(req *http.Request) (*http.Response, error) {
   371  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   372  }
   373  
   374  // GetNotebooksByWorkspaceResponder handles the response to the GetNotebooksByWorkspace request. The method always
   375  // closes the http.Response Body.
   376  func (client NotebookClient) GetNotebooksByWorkspaceResponder(resp *http.Response) (result NotebookListResponse, err error) {
   377  	err = autorest.Respond(
   378  		resp,
   379  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   380  		autorest.ByUnmarshallingJSON(&result),
   381  		autorest.ByClosing())
   382  	result.Response = autorest.Response{Response: resp}
   383  	return
   384  }
   385  
   386  // getNotebooksByWorkspaceNextResults retrieves the next set of results, if any.
   387  func (client NotebookClient) getNotebooksByWorkspaceNextResults(ctx context.Context, lastResults NotebookListResponse) (result NotebookListResponse, err error) {
   388  	req, err := lastResults.notebookListResponsePreparer(ctx)
   389  	if err != nil {
   390  		return result, autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebooksByWorkspaceNextResults", nil, "Failure preparing next results request")
   391  	}
   392  	if req == nil {
   393  		return
   394  	}
   395  	resp, err := client.GetNotebooksByWorkspaceSender(req)
   396  	if err != nil {
   397  		result.Response = autorest.Response{Response: resp}
   398  		return result, autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebooksByWorkspaceNextResults", resp, "Failure sending next results request")
   399  	}
   400  	result, err = client.GetNotebooksByWorkspaceResponder(resp)
   401  	if err != nil {
   402  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebooksByWorkspaceNextResults", resp, "Failure responding to next results request")
   403  	}
   404  	return
   405  }
   406  
   407  // GetNotebooksByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
   408  func (client NotebookClient) GetNotebooksByWorkspaceComplete(ctx context.Context) (result NotebookListResponseIterator, err error) {
   409  	if tracing.IsEnabled() {
   410  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.GetNotebooksByWorkspace")
   411  		defer func() {
   412  			sc := -1
   413  			if result.Response().Response.Response != nil {
   414  				sc = result.page.Response().Response.Response.StatusCode
   415  			}
   416  			tracing.EndSpan(ctx, sc, err)
   417  		}()
   418  	}
   419  	result.page, err = client.GetNotebooksByWorkspace(ctx)
   420  	return
   421  }
   422  
   423  // GetNotebookSummaryByWorkSpace lists a summary of Notebooks.
   424  func (client NotebookClient) GetNotebookSummaryByWorkSpace(ctx context.Context) (result NotebookListResponsePage, err error) {
   425  	if tracing.IsEnabled() {
   426  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.GetNotebookSummaryByWorkSpace")
   427  		defer func() {
   428  			sc := -1
   429  			if result.nlr.Response.Response != nil {
   430  				sc = result.nlr.Response.Response.StatusCode
   431  			}
   432  			tracing.EndSpan(ctx, sc, err)
   433  		}()
   434  	}
   435  	result.fn = client.getNotebookSummaryByWorkSpaceNextResults
   436  	req, err := client.GetNotebookSummaryByWorkSpacePreparer(ctx)
   437  	if err != nil {
   438  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebookSummaryByWorkSpace", nil, "Failure preparing request")
   439  		return
   440  	}
   441  
   442  	resp, err := client.GetNotebookSummaryByWorkSpaceSender(req)
   443  	if err != nil {
   444  		result.nlr.Response = autorest.Response{Response: resp}
   445  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebookSummaryByWorkSpace", resp, "Failure sending request")
   446  		return
   447  	}
   448  
   449  	result.nlr, err = client.GetNotebookSummaryByWorkSpaceResponder(resp)
   450  	if err != nil {
   451  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "GetNotebookSummaryByWorkSpace", resp, "Failure responding to request")
   452  		return
   453  	}
   454  	if result.nlr.hasNextLink() && result.nlr.IsEmpty() {
   455  		err = result.NextWithContext(ctx)
   456  		return
   457  	}
   458  
   459  	return
   460  }
   461  
   462  // GetNotebookSummaryByWorkSpacePreparer prepares the GetNotebookSummaryByWorkSpace request.
   463  func (client NotebookClient) GetNotebookSummaryByWorkSpacePreparer(ctx context.Context) (*http.Request, error) {
   464  	urlParameters := map[string]interface{}{
   465  		"endpoint": client.Endpoint,
   466  	}
   467  
   468  	const APIVersion = "2019-06-01-preview"
   469  	queryParameters := map[string]interface{}{
   470  		"api-version": APIVersion,
   471  	}
   472  
   473  	preparer := autorest.CreatePreparer(
   474  		autorest.AsGet(),
   475  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   476  		autorest.WithPath("/notebooks/summary"),
   477  		autorest.WithQueryParameters(queryParameters))
   478  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   479  }
   480  
   481  // GetNotebookSummaryByWorkSpaceSender sends the GetNotebookSummaryByWorkSpace request. The method will close the
   482  // http.Response Body if it receives an error.
   483  func (client NotebookClient) GetNotebookSummaryByWorkSpaceSender(req *http.Request) (*http.Response, error) {
   484  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   485  }
   486  
   487  // GetNotebookSummaryByWorkSpaceResponder handles the response to the GetNotebookSummaryByWorkSpace request. The method always
   488  // closes the http.Response Body.
   489  func (client NotebookClient) GetNotebookSummaryByWorkSpaceResponder(resp *http.Response) (result NotebookListResponse, err error) {
   490  	err = autorest.Respond(
   491  		resp,
   492  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   493  		autorest.ByUnmarshallingJSON(&result),
   494  		autorest.ByClosing())
   495  	result.Response = autorest.Response{Response: resp}
   496  	return
   497  }
   498  
   499  // getNotebookSummaryByWorkSpaceNextResults retrieves the next set of results, if any.
   500  func (client NotebookClient) getNotebookSummaryByWorkSpaceNextResults(ctx context.Context, lastResults NotebookListResponse) (result NotebookListResponse, err error) {
   501  	req, err := lastResults.notebookListResponsePreparer(ctx)
   502  	if err != nil {
   503  		return result, autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebookSummaryByWorkSpaceNextResults", nil, "Failure preparing next results request")
   504  	}
   505  	if req == nil {
   506  		return
   507  	}
   508  	resp, err := client.GetNotebookSummaryByWorkSpaceSender(req)
   509  	if err != nil {
   510  		result.Response = autorest.Response{Response: resp}
   511  		return result, autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebookSummaryByWorkSpaceNextResults", resp, "Failure sending next results request")
   512  	}
   513  	result, err = client.GetNotebookSummaryByWorkSpaceResponder(resp)
   514  	if err != nil {
   515  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "getNotebookSummaryByWorkSpaceNextResults", resp, "Failure responding to next results request")
   516  	}
   517  	return
   518  }
   519  
   520  // GetNotebookSummaryByWorkSpaceComplete enumerates all values, automatically crossing page boundaries as required.
   521  func (client NotebookClient) GetNotebookSummaryByWorkSpaceComplete(ctx context.Context) (result NotebookListResponseIterator, err error) {
   522  	if tracing.IsEnabled() {
   523  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.GetNotebookSummaryByWorkSpace")
   524  		defer func() {
   525  			sc := -1
   526  			if result.Response().Response.Response != nil {
   527  				sc = result.page.Response().Response.Response.StatusCode
   528  			}
   529  			tracing.EndSpan(ctx, sc, err)
   530  		}()
   531  	}
   532  	result.page, err = client.GetNotebookSummaryByWorkSpace(ctx)
   533  	return
   534  }
   535  
   536  // RenameNotebook renames a notebook.
   537  // Parameters:
   538  // notebookName - the notebook name.
   539  // request - proposed new name.
   540  func (client NotebookClient) RenameNotebook(ctx context.Context, notebookName string, request RenameRequest) (result NotebookRenameNotebookFuture, err error) {
   541  	if tracing.IsEnabled() {
   542  		ctx = tracing.StartSpan(ctx, fqdn+"/NotebookClient.RenameNotebook")
   543  		defer func() {
   544  			sc := -1
   545  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   546  				sc = result.FutureAPI.Response().StatusCode
   547  			}
   548  			tracing.EndSpan(ctx, sc, err)
   549  		}()
   550  	}
   551  	if err := validation.Validate([]validation.Validation{
   552  		{TargetValue: request,
   553  			Constraints: []validation.Constraint{{Target: "request.NewName", Name: validation.Null, Rule: false,
   554  				Chain: []validation.Constraint{{Target: "request.NewName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   555  					{Target: "request.NewName", Name: validation.MinLength, Rule: 1, Chain: nil},
   556  					{Target: "request.NewName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil},
   557  				}}}}}); err != nil {
   558  		return result, validation.NewError("artifacts.NotebookClient", "RenameNotebook", err.Error())
   559  	}
   560  
   561  	req, err := client.RenameNotebookPreparer(ctx, notebookName, request)
   562  	if err != nil {
   563  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "RenameNotebook", nil, "Failure preparing request")
   564  		return
   565  	}
   566  
   567  	result, err = client.RenameNotebookSender(req)
   568  	if err != nil {
   569  		err = autorest.NewErrorWithError(err, "artifacts.NotebookClient", "RenameNotebook", nil, "Failure sending request")
   570  		return
   571  	}
   572  
   573  	return
   574  }
   575  
   576  // RenameNotebookPreparer prepares the RenameNotebook request.
   577  func (client NotebookClient) RenameNotebookPreparer(ctx context.Context, notebookName string, request RenameRequest) (*http.Request, error) {
   578  	urlParameters := map[string]interface{}{
   579  		"endpoint": client.Endpoint,
   580  	}
   581  
   582  	pathParameters := map[string]interface{}{
   583  		"notebookName": autorest.Encode("path", notebookName),
   584  	}
   585  
   586  	const APIVersion = "2019-06-01-preview"
   587  	queryParameters := map[string]interface{}{
   588  		"api-version": APIVersion,
   589  	}
   590  
   591  	preparer := autorest.CreatePreparer(
   592  		autorest.AsContentType("application/json; charset=utf-8"),
   593  		autorest.AsPost(),
   594  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   595  		autorest.WithPathParameters("/notebooks/{notebookName}/rename", pathParameters),
   596  		autorest.WithJSON(request),
   597  		autorest.WithQueryParameters(queryParameters))
   598  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   599  }
   600  
   601  // RenameNotebookSender sends the RenameNotebook request. The method will close the
   602  // http.Response Body if it receives an error.
   603  func (client NotebookClient) RenameNotebookSender(req *http.Request) (future NotebookRenameNotebookFuture, err error) {
   604  	var resp *http.Response
   605  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   606  	if err != nil {
   607  		return
   608  	}
   609  	var azf azure.Future
   610  	azf, err = azure.NewFutureFromResponse(resp)
   611  	future.FutureAPI = &azf
   612  	future.Result = future.result
   613  	return
   614  }
   615  
   616  // RenameNotebookResponder handles the response to the RenameNotebook request. The method always
   617  // closes the http.Response Body.
   618  func (client NotebookClient) RenameNotebookResponder(resp *http.Response) (result autorest.Response, err error) {
   619  	err = autorest.Respond(
   620  		resp,
   621  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   622  		autorest.ByClosing())
   623  	result.Response = resp
   624  	return
   625  }
   626  

View as plain text