...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2017-05-01-preview/experimentation/projects.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2017-05-01-preview/experimentation

     1  package experimentation
     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  // ProjectsClient is the these APIs allow end users to operate on Azure Machine Learning Team Account resources. They
    19  // support CRUD operations for Azure Machine Learning Team Accounts.
    20  type ProjectsClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewProjectsClient creates an instance of the ProjectsClient client.
    25  func NewProjectsClient(subscriptionID string) ProjectsClient {
    26  	return NewProjectsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewProjectsClientWithBaseURI creates an instance of the ProjectsClient client using a custom endpoint.  Use this
    30  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewProjectsClientWithBaseURI(baseURI string, subscriptionID string) ProjectsClient {
    32  	return ProjectsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates or updates a project with the specified parameters.
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group to which the machine learning team account belongs.
    38  // accountName - the name of the machine learning team account.
    39  // workspaceName - the name of the machine learning team account workspace.
    40  // projectName - the name of the machine learning project under a team account workspace.
    41  // parameters - the parameters for creating or updating a project.
    42  func (client ProjectsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string, parameters Project) (result Project, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.Response.Response != nil {
    48  				sc = result.Response.Response.StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: accountName,
    55  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    56  				{Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil},
    57  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
    58  		{TargetValue: workspaceName,
    59  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    60  				{Target: "workspaceName", Name: validation.MinLength, Rule: 5, Chain: nil},
    61  				{Target: "workspaceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
    62  		{TargetValue: projectName,
    63  			Constraints: []validation.Constraint{{Target: "projectName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    64  				{Target: "projectName", Name: validation.MinLength, Rule: 5, Chain: nil},
    65  				{Target: "projectName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
    66  		{TargetValue: parameters,
    67  			Constraints: []validation.Constraint{{Target: "parameters.ProjectProperties", Name: validation.Null, Rule: false,
    68  				Chain: []validation.Constraint{{Target: "parameters.ProjectProperties.FriendlyName", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
    69  		return result, validation.NewError("experimentation.ProjectsClient", "CreateOrUpdate", err.Error())
    70  	}
    71  
    72  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, workspaceName, projectName, parameters)
    73  	if err != nil {
    74  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "CreateOrUpdate", nil, "Failure preparing request")
    75  		return
    76  	}
    77  
    78  	resp, err := client.CreateOrUpdateSender(req)
    79  	if err != nil {
    80  		result.Response = autorest.Response{Response: resp}
    81  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "CreateOrUpdate", resp, "Failure sending request")
    82  		return
    83  	}
    84  
    85  	result, err = client.CreateOrUpdateResponder(resp)
    86  	if err != nil {
    87  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "CreateOrUpdate", resp, "Failure responding to request")
    88  		return
    89  	}
    90  
    91  	return
    92  }
    93  
    94  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    95  func (client ProjectsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string, parameters Project) (*http.Request, error) {
    96  	pathParameters := map[string]interface{}{
    97  		"accountName":       autorest.Encode("path", accountName),
    98  		"projectName":       autorest.Encode("path", projectName),
    99  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   100  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   101  		"workspaceName":     autorest.Encode("path", workspaceName),
   102  	}
   103  
   104  	const APIVersion = "2017-05-01-preview"
   105  	queryParameters := map[string]interface{}{
   106  		"api-version": APIVersion,
   107  	}
   108  
   109  	preparer := autorest.CreatePreparer(
   110  		autorest.AsContentType("application/json; charset=utf-8"),
   111  		autorest.AsPut(),
   112  		autorest.WithBaseURL(client.BaseURI),
   113  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}/workspaces/{workspaceName}/projects/{projectName}", pathParameters),
   114  		autorest.WithJSON(parameters),
   115  		autorest.WithQueryParameters(queryParameters))
   116  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   117  }
   118  
   119  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   120  // http.Response Body if it receives an error.
   121  func (client ProjectsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   122  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   123  }
   124  
   125  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   126  // closes the http.Response Body.
   127  func (client ProjectsClient) CreateOrUpdateResponder(resp *http.Response) (result Project, err error) {
   128  	err = autorest.Respond(
   129  		resp,
   130  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   131  		autorest.ByUnmarshallingJSON(&result),
   132  		autorest.ByClosing())
   133  	result.Response = autorest.Response{Response: resp}
   134  	return
   135  }
   136  
   137  // Delete deletes a project.
   138  // Parameters:
   139  // resourceGroupName - the name of the resource group to which the machine learning team account belongs.
   140  // accountName - the name of the machine learning team account.
   141  // workspaceName - the name of the machine learning team account workspace.
   142  // projectName - the name of the machine learning project under a team account workspace.
   143  func (client ProjectsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string) (result autorest.Response, err error) {
   144  	if tracing.IsEnabled() {
   145  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.Delete")
   146  		defer func() {
   147  			sc := -1
   148  			if result.Response != nil {
   149  				sc = result.Response.StatusCode
   150  			}
   151  			tracing.EndSpan(ctx, sc, err)
   152  		}()
   153  	}
   154  	if err := validation.Validate([]validation.Validation{
   155  		{TargetValue: accountName,
   156  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   157  				{Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil},
   158  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   159  		{TargetValue: workspaceName,
   160  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   161  				{Target: "workspaceName", Name: validation.MinLength, Rule: 5, Chain: nil},
   162  				{Target: "workspaceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   163  		{TargetValue: projectName,
   164  			Constraints: []validation.Constraint{{Target: "projectName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   165  				{Target: "projectName", Name: validation.MinLength, Rule: 5, Chain: nil},
   166  				{Target: "projectName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
   167  		return result, validation.NewError("experimentation.ProjectsClient", "Delete", err.Error())
   168  	}
   169  
   170  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, workspaceName, projectName)
   171  	if err != nil {
   172  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Delete", nil, "Failure preparing request")
   173  		return
   174  	}
   175  
   176  	resp, err := client.DeleteSender(req)
   177  	if err != nil {
   178  		result.Response = resp
   179  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Delete", resp, "Failure sending request")
   180  		return
   181  	}
   182  
   183  	result, err = client.DeleteResponder(resp)
   184  	if err != nil {
   185  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Delete", resp, "Failure responding to request")
   186  		return
   187  	}
   188  
   189  	return
   190  }
   191  
   192  // DeletePreparer prepares the Delete request.
   193  func (client ProjectsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string) (*http.Request, error) {
   194  	pathParameters := map[string]interface{}{
   195  		"accountName":       autorest.Encode("path", accountName),
   196  		"projectName":       autorest.Encode("path", projectName),
   197  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   198  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   199  		"workspaceName":     autorest.Encode("path", workspaceName),
   200  	}
   201  
   202  	const APIVersion = "2017-05-01-preview"
   203  	queryParameters := map[string]interface{}{
   204  		"api-version": APIVersion,
   205  	}
   206  
   207  	preparer := autorest.CreatePreparer(
   208  		autorest.AsDelete(),
   209  		autorest.WithBaseURL(client.BaseURI),
   210  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}/workspaces/{workspaceName}/projects/{projectName}", pathParameters),
   211  		autorest.WithQueryParameters(queryParameters))
   212  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   213  }
   214  
   215  // DeleteSender sends the Delete request. The method will close the
   216  // http.Response Body if it receives an error.
   217  func (client ProjectsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   218  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   219  }
   220  
   221  // DeleteResponder handles the response to the Delete request. The method always
   222  // closes the http.Response Body.
   223  func (client ProjectsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   224  	err = autorest.Respond(
   225  		resp,
   226  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   227  		autorest.ByClosing())
   228  	result.Response = resp
   229  	return
   230  }
   231  
   232  // Get gets the properties of the specified machine learning project.
   233  // Parameters:
   234  // resourceGroupName - the name of the resource group to which the machine learning team account belongs.
   235  // accountName - the name of the machine learning team account.
   236  // workspaceName - the name of the machine learning team account workspace.
   237  // projectName - the name of the machine learning project under a team account workspace.
   238  func (client ProjectsClient) Get(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string) (result Project, err error) {
   239  	if tracing.IsEnabled() {
   240  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.Get")
   241  		defer func() {
   242  			sc := -1
   243  			if result.Response.Response != nil {
   244  				sc = result.Response.Response.StatusCode
   245  			}
   246  			tracing.EndSpan(ctx, sc, err)
   247  		}()
   248  	}
   249  	if err := validation.Validate([]validation.Validation{
   250  		{TargetValue: accountName,
   251  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   252  				{Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil},
   253  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   254  		{TargetValue: workspaceName,
   255  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   256  				{Target: "workspaceName", Name: validation.MinLength, Rule: 5, Chain: nil},
   257  				{Target: "workspaceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   258  		{TargetValue: projectName,
   259  			Constraints: []validation.Constraint{{Target: "projectName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   260  				{Target: "projectName", Name: validation.MinLength, Rule: 5, Chain: nil},
   261  				{Target: "projectName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
   262  		return result, validation.NewError("experimentation.ProjectsClient", "Get", err.Error())
   263  	}
   264  
   265  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, workspaceName, projectName)
   266  	if err != nil {
   267  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Get", nil, "Failure preparing request")
   268  		return
   269  	}
   270  
   271  	resp, err := client.GetSender(req)
   272  	if err != nil {
   273  		result.Response = autorest.Response{Response: resp}
   274  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Get", resp, "Failure sending request")
   275  		return
   276  	}
   277  
   278  	result, err = client.GetResponder(resp)
   279  	if err != nil {
   280  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Get", resp, "Failure responding to request")
   281  		return
   282  	}
   283  
   284  	return
   285  }
   286  
   287  // GetPreparer prepares the Get request.
   288  func (client ProjectsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string) (*http.Request, error) {
   289  	pathParameters := map[string]interface{}{
   290  		"accountName":       autorest.Encode("path", accountName),
   291  		"projectName":       autorest.Encode("path", projectName),
   292  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   293  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   294  		"workspaceName":     autorest.Encode("path", workspaceName),
   295  	}
   296  
   297  	const APIVersion = "2017-05-01-preview"
   298  	queryParameters := map[string]interface{}{
   299  		"api-version": APIVersion,
   300  	}
   301  
   302  	preparer := autorest.CreatePreparer(
   303  		autorest.AsGet(),
   304  		autorest.WithBaseURL(client.BaseURI),
   305  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}/workspaces/{workspaceName}/projects/{projectName}", pathParameters),
   306  		autorest.WithQueryParameters(queryParameters))
   307  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   308  }
   309  
   310  // GetSender sends the Get request. The method will close the
   311  // http.Response Body if it receives an error.
   312  func (client ProjectsClient) GetSender(req *http.Request) (*http.Response, error) {
   313  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   314  }
   315  
   316  // GetResponder handles the response to the Get request. The method always
   317  // closes the http.Response Body.
   318  func (client ProjectsClient) GetResponder(resp *http.Response) (result Project, err error) {
   319  	err = autorest.Respond(
   320  		resp,
   321  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   322  		autorest.ByUnmarshallingJSON(&result),
   323  		autorest.ByClosing())
   324  	result.Response = autorest.Response{Response: resp}
   325  	return
   326  }
   327  
   328  // ListByWorkspace lists all the available machine learning projects under the specified workspace.
   329  // Parameters:
   330  // accountName - the name of the machine learning team account.
   331  // workspaceName - the name of the machine learning team account workspace.
   332  // resourceGroupName - the name of the resource group to which the machine learning team account belongs.
   333  func (client ProjectsClient) ListByWorkspace(ctx context.Context, accountName string, workspaceName string, resourceGroupName string) (result ProjectListResultPage, err error) {
   334  	if tracing.IsEnabled() {
   335  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.ListByWorkspace")
   336  		defer func() {
   337  			sc := -1
   338  			if result.plr.Response.Response != nil {
   339  				sc = result.plr.Response.Response.StatusCode
   340  			}
   341  			tracing.EndSpan(ctx, sc, err)
   342  		}()
   343  	}
   344  	if err := validation.Validate([]validation.Validation{
   345  		{TargetValue: accountName,
   346  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   347  				{Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil},
   348  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   349  		{TargetValue: workspaceName,
   350  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   351  				{Target: "workspaceName", Name: validation.MinLength, Rule: 5, Chain: nil},
   352  				{Target: "workspaceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
   353  		return result, validation.NewError("experimentation.ProjectsClient", "ListByWorkspace", err.Error())
   354  	}
   355  
   356  	result.fn = client.listByWorkspaceNextResults
   357  	req, err := client.ListByWorkspacePreparer(ctx, accountName, workspaceName, resourceGroupName)
   358  	if err != nil {
   359  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "ListByWorkspace", nil, "Failure preparing request")
   360  		return
   361  	}
   362  
   363  	resp, err := client.ListByWorkspaceSender(req)
   364  	if err != nil {
   365  		result.plr.Response = autorest.Response{Response: resp}
   366  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "ListByWorkspace", resp, "Failure sending request")
   367  		return
   368  	}
   369  
   370  	result.plr, err = client.ListByWorkspaceResponder(resp)
   371  	if err != nil {
   372  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "ListByWorkspace", resp, "Failure responding to request")
   373  		return
   374  	}
   375  	if result.plr.hasNextLink() && result.plr.IsEmpty() {
   376  		err = result.NextWithContext(ctx)
   377  		return
   378  	}
   379  
   380  	return
   381  }
   382  
   383  // ListByWorkspacePreparer prepares the ListByWorkspace request.
   384  func (client ProjectsClient) ListByWorkspacePreparer(ctx context.Context, accountName string, workspaceName string, resourceGroupName string) (*http.Request, error) {
   385  	pathParameters := map[string]interface{}{
   386  		"accountName":       autorest.Encode("path", accountName),
   387  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   388  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   389  		"workspaceName":     autorest.Encode("path", workspaceName),
   390  	}
   391  
   392  	const APIVersion = "2017-05-01-preview"
   393  	queryParameters := map[string]interface{}{
   394  		"api-version": APIVersion,
   395  	}
   396  
   397  	preparer := autorest.CreatePreparer(
   398  		autorest.AsGet(),
   399  		autorest.WithBaseURL(client.BaseURI),
   400  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}/workspaces{workspaceName}/projects", pathParameters),
   401  		autorest.WithQueryParameters(queryParameters))
   402  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   403  }
   404  
   405  // ListByWorkspaceSender sends the ListByWorkspace request. The method will close the
   406  // http.Response Body if it receives an error.
   407  func (client ProjectsClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) {
   408  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   409  }
   410  
   411  // ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always
   412  // closes the http.Response Body.
   413  func (client ProjectsClient) ListByWorkspaceResponder(resp *http.Response) (result ProjectListResult, err error) {
   414  	err = autorest.Respond(
   415  		resp,
   416  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   417  		autorest.ByUnmarshallingJSON(&result),
   418  		autorest.ByClosing())
   419  	result.Response = autorest.Response{Response: resp}
   420  	return
   421  }
   422  
   423  // listByWorkspaceNextResults retrieves the next set of results, if any.
   424  func (client ProjectsClient) listByWorkspaceNextResults(ctx context.Context, lastResults ProjectListResult) (result ProjectListResult, err error) {
   425  	req, err := lastResults.projectListResultPreparer(ctx)
   426  	if err != nil {
   427  		return result, autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request")
   428  	}
   429  	if req == nil {
   430  		return
   431  	}
   432  	resp, err := client.ListByWorkspaceSender(req)
   433  	if err != nil {
   434  		result.Response = autorest.Response{Response: resp}
   435  		return result, autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "listByWorkspaceNextResults", resp, "Failure sending next results request")
   436  	}
   437  	result, err = client.ListByWorkspaceResponder(resp)
   438  	if err != nil {
   439  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request")
   440  	}
   441  	return
   442  }
   443  
   444  // ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
   445  func (client ProjectsClient) ListByWorkspaceComplete(ctx context.Context, accountName string, workspaceName string, resourceGroupName string) (result ProjectListResultIterator, err error) {
   446  	if tracing.IsEnabled() {
   447  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.ListByWorkspace")
   448  		defer func() {
   449  			sc := -1
   450  			if result.Response().Response.Response != nil {
   451  				sc = result.page.Response().Response.Response.StatusCode
   452  			}
   453  			tracing.EndSpan(ctx, sc, err)
   454  		}()
   455  	}
   456  	result.page, err = client.ListByWorkspace(ctx, accountName, workspaceName, resourceGroupName)
   457  	return
   458  }
   459  
   460  // Update updates a project with the specified parameters.
   461  // Parameters:
   462  // resourceGroupName - the name of the resource group to which the machine learning team account belongs.
   463  // accountName - the name of the machine learning team account.
   464  // workspaceName - the name of the machine learning team account workspace.
   465  // projectName - the name of the machine learning project under a team account workspace.
   466  // parameters - the parameters for updating a machine learning team account.
   467  func (client ProjectsClient) Update(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string, parameters ProjectUpdateParameters) (result Project, err error) {
   468  	if tracing.IsEnabled() {
   469  		ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.Update")
   470  		defer func() {
   471  			sc := -1
   472  			if result.Response.Response != nil {
   473  				sc = result.Response.Response.StatusCode
   474  			}
   475  			tracing.EndSpan(ctx, sc, err)
   476  		}()
   477  	}
   478  	if err := validation.Validate([]validation.Validation{
   479  		{TargetValue: accountName,
   480  			Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   481  				{Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil},
   482  				{Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   483  		{TargetValue: workspaceName,
   484  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   485  				{Target: "workspaceName", Name: validation.MinLength, Rule: 5, Chain: nil},
   486  				{Target: "workspaceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
   487  		{TargetValue: projectName,
   488  			Constraints: []validation.Constraint{{Target: "projectName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   489  				{Target: "projectName", Name: validation.MinLength, Rule: 5, Chain: nil},
   490  				{Target: "projectName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
   491  		return result, validation.NewError("experimentation.ProjectsClient", "Update", err.Error())
   492  	}
   493  
   494  	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, workspaceName, projectName, parameters)
   495  	if err != nil {
   496  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Update", nil, "Failure preparing request")
   497  		return
   498  	}
   499  
   500  	resp, err := client.UpdateSender(req)
   501  	if err != nil {
   502  		result.Response = autorest.Response{Response: resp}
   503  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Update", resp, "Failure sending request")
   504  		return
   505  	}
   506  
   507  	result, err = client.UpdateResponder(resp)
   508  	if err != nil {
   509  		err = autorest.NewErrorWithError(err, "experimentation.ProjectsClient", "Update", resp, "Failure responding to request")
   510  		return
   511  	}
   512  
   513  	return
   514  }
   515  
   516  // UpdatePreparer prepares the Update request.
   517  func (client ProjectsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, workspaceName string, projectName string, parameters ProjectUpdateParameters) (*http.Request, error) {
   518  	pathParameters := map[string]interface{}{
   519  		"accountName":       autorest.Encode("path", accountName),
   520  		"projectName":       autorest.Encode("path", projectName),
   521  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   522  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   523  		"workspaceName":     autorest.Encode("path", workspaceName),
   524  	}
   525  
   526  	const APIVersion = "2017-05-01-preview"
   527  	queryParameters := map[string]interface{}{
   528  		"api-version": APIVersion,
   529  	}
   530  
   531  	preparer := autorest.CreatePreparer(
   532  		autorest.AsContentType("application/json; charset=utf-8"),
   533  		autorest.AsPatch(),
   534  		autorest.WithBaseURL(client.BaseURI),
   535  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}/workspaces/{workspaceName}/projects/{projectName}", pathParameters),
   536  		autorest.WithJSON(parameters),
   537  		autorest.WithQueryParameters(queryParameters))
   538  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   539  }
   540  
   541  // UpdateSender sends the Update request. The method will close the
   542  // http.Response Body if it receives an error.
   543  func (client ProjectsClient) UpdateSender(req *http.Request) (*http.Response, error) {
   544  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   545  }
   546  
   547  // UpdateResponder handles the response to the Update request. The method always
   548  // closes the http.Response Body.
   549  func (client ProjectsClient) UpdateResponder(resp *http.Response) (result Project, err error) {
   550  	err = autorest.Respond(
   551  		resp,
   552  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   553  		autorest.ByUnmarshallingJSON(&result),
   554  		autorest.ByClosing())
   555  	result.Response = autorest.Response{Response: resp}
   556  	return
   557  }
   558  

View as plain text