...

Source file src/github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2019-10-01/workspaces/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2019-10-01/workspaces

     1  package workspaces
     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  	"encoding/json"
    12  	"github.com/Azure/go-autorest/autorest"
    13  	"github.com/Azure/go-autorest/autorest/to"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // The package's fully qualified name.
    19  const fqdn = "github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2019-10-01/workspaces"
    20  
    21  // ErrorResponse the error response send when an operation fails.
    22  type ErrorResponse struct {
    23  	// Code - error code
    24  	Code *string `json:"code,omitempty"`
    25  	// Message - error message
    26  	Message *string `json:"message,omitempty"`
    27  }
    28  
    29  // KeysResponse workspace authorization keys for a workspace.
    30  type KeysResponse struct {
    31  	autorest.Response `json:"-"`
    32  	// PrimaryToken - Primary authorization key for this workspace.
    33  	PrimaryToken *string `json:"primaryToken,omitempty"`
    34  	// SecondaryToken - Secondary authorization key for this workspace.
    35  	SecondaryToken *string `json:"secondaryToken,omitempty"`
    36  }
    37  
    38  // ListResult the result of a request to list machine learning workspace keys.
    39  type ListResult struct {
    40  	autorest.Response `json:"-"`
    41  	// Value - The list of machine learning workspaces. Since this list may be incomplete, the nextLink field should be used to request the next list of machine learning workspaces.
    42  	Value *[]Workspace `json:"value,omitempty"`
    43  	// NextLink - The URI that can be used to request the next list of machine learning workspaces.
    44  	NextLink *string `json:"nextLink,omitempty"`
    45  }
    46  
    47  // ListResultIterator provides access to a complete listing of Workspace values.
    48  type ListResultIterator struct {
    49  	i    int
    50  	page ListResultPage
    51  }
    52  
    53  // NextWithContext advances to the next value.  If there was an error making
    54  // the request the iterator does not advance and the error is returned.
    55  func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
    56  	if tracing.IsEnabled() {
    57  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
    58  		defer func() {
    59  			sc := -1
    60  			if iter.Response().Response.Response != nil {
    61  				sc = iter.Response().Response.Response.StatusCode
    62  			}
    63  			tracing.EndSpan(ctx, sc, err)
    64  		}()
    65  	}
    66  	iter.i++
    67  	if iter.i < len(iter.page.Values()) {
    68  		return nil
    69  	}
    70  	err = iter.page.NextWithContext(ctx)
    71  	if err != nil {
    72  		iter.i--
    73  		return err
    74  	}
    75  	iter.i = 0
    76  	return nil
    77  }
    78  
    79  // Next advances to the next value.  If there was an error making
    80  // the request the iterator does not advance and the error is returned.
    81  // Deprecated: Use NextWithContext() instead.
    82  func (iter *ListResultIterator) Next() error {
    83  	return iter.NextWithContext(context.Background())
    84  }
    85  
    86  // NotDone returns true if the enumeration should be started or is not yet complete.
    87  func (iter ListResultIterator) NotDone() bool {
    88  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
    89  }
    90  
    91  // Response returns the raw server response from the last page request.
    92  func (iter ListResultIterator) Response() ListResult {
    93  	return iter.page.Response()
    94  }
    95  
    96  // Value returns the current value or a zero-initialized value if the
    97  // iterator has advanced beyond the end of the collection.
    98  func (iter ListResultIterator) Value() Workspace {
    99  	if !iter.page.NotDone() {
   100  		return Workspace{}
   101  	}
   102  	return iter.page.Values()[iter.i]
   103  }
   104  
   105  // Creates a new instance of the ListResultIterator type.
   106  func NewListResultIterator(page ListResultPage) ListResultIterator {
   107  	return ListResultIterator{page: page}
   108  }
   109  
   110  // IsEmpty returns true if the ListResult contains no values.
   111  func (lr ListResult) IsEmpty() bool {
   112  	return lr.Value == nil || len(*lr.Value) == 0
   113  }
   114  
   115  // hasNextLink returns true if the NextLink is not empty.
   116  func (lr ListResult) hasNextLink() bool {
   117  	return lr.NextLink != nil && len(*lr.NextLink) != 0
   118  }
   119  
   120  // listResultPreparer prepares a request to retrieve the next set of results.
   121  // It returns nil if no more results exist.
   122  func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
   123  	if !lr.hasNextLink() {
   124  		return nil, nil
   125  	}
   126  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   127  		autorest.AsJSON(),
   128  		autorest.AsGet(),
   129  		autorest.WithBaseURL(to.String(lr.NextLink)))
   130  }
   131  
   132  // ListResultPage contains a page of Workspace values.
   133  type ListResultPage struct {
   134  	fn func(context.Context, ListResult) (ListResult, error)
   135  	lr ListResult
   136  }
   137  
   138  // NextWithContext advances to the next page of values.  If there was an error making
   139  // the request the page does not advance and the error is returned.
   140  func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
   141  	if tracing.IsEnabled() {
   142  		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
   143  		defer func() {
   144  			sc := -1
   145  			if page.Response().Response.Response != nil {
   146  				sc = page.Response().Response.Response.StatusCode
   147  			}
   148  			tracing.EndSpan(ctx, sc, err)
   149  		}()
   150  	}
   151  	for {
   152  		next, err := page.fn(ctx, page.lr)
   153  		if err != nil {
   154  			return err
   155  		}
   156  		page.lr = next
   157  		if !next.hasNextLink() || !next.IsEmpty() {
   158  			break
   159  		}
   160  	}
   161  	return nil
   162  }
   163  
   164  // Next advances to the next page of values.  If there was an error making
   165  // the request the page does not advance and the error is returned.
   166  // Deprecated: Use NextWithContext() instead.
   167  func (page *ListResultPage) Next() error {
   168  	return page.NextWithContext(context.Background())
   169  }
   170  
   171  // NotDone returns true if the page enumeration should be started or is not yet complete.
   172  func (page ListResultPage) NotDone() bool {
   173  	return !page.lr.IsEmpty()
   174  }
   175  
   176  // Response returns the raw server response from the last page request.
   177  func (page ListResultPage) Response() ListResult {
   178  	return page.lr
   179  }
   180  
   181  // Values returns the slice of values for the current page or nil if there are no values.
   182  func (page ListResultPage) Values() []Workspace {
   183  	if page.lr.IsEmpty() {
   184  		return nil
   185  	}
   186  	return *page.lr.Value
   187  }
   188  
   189  // Creates a new instance of the ListResultPage type.
   190  func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
   191  	return ListResultPage{
   192  		fn: getNextPage,
   193  		lr: cur,
   194  	}
   195  }
   196  
   197  // Operation azure Machine Learning Studio REST API operation
   198  type Operation struct {
   199  	// Name - Operation name: {provider}/{resource}/{operation}
   200  	Name *string `json:"name,omitempty"`
   201  	// Display - Display name of operation
   202  	Display *OperationDisplay `json:"display,omitempty"`
   203  }
   204  
   205  // OperationDisplay display name of operation
   206  type OperationDisplay struct {
   207  	// Provider - The resource provider name: Microsoft.MachineLearning
   208  	Provider *string `json:"provider,omitempty"`
   209  	// Resource - The resource on which the operation is performed.
   210  	Resource *string `json:"resource,omitempty"`
   211  	// Operation - The operation that users can perform.
   212  	Operation *string `json:"operation,omitempty"`
   213  	// Description - The description for the operation.
   214  	Description *string `json:"description,omitempty"`
   215  }
   216  
   217  // OperationListResult an array of operations supported by the resource provider.
   218  type OperationListResult struct {
   219  	autorest.Response `json:"-"`
   220  	// Value - List of AML Studio operations supported by the AML Studio resource provider.
   221  	Value *[]Operation `json:"value,omitempty"`
   222  }
   223  
   224  // Properties the properties of a machine learning workspace.
   225  type Properties struct {
   226  	// UserStorageAccountID - The fully qualified arm id of the storage account associated with this workspace.
   227  	UserStorageAccountID *string `json:"userStorageAccountId,omitempty"`
   228  	// OwnerEmail - The email id of the owner for this workspace.
   229  	OwnerEmail *string `json:"ownerEmail,omitempty"`
   230  	// WorkspaceType - READ-ONLY; The type of this workspace. Possible values include: 'Production', 'Free', 'Anonymous', 'PaidStandard', 'PaidPremium'
   231  	WorkspaceType WorkspaceType `json:"workspaceType,omitempty"`
   232  	// WorkspaceState - READ-ONLY; The current state of workspace resource. Possible values include: 'Deleted', 'Enabled', 'Disabled', 'Migrated', 'Updated', 'Registered', 'Unregistered'
   233  	WorkspaceState State `json:"workspaceState,omitempty"`
   234  	// WorkspaceID - READ-ONLY; The immutable id associated with this workspace.
   235  	WorkspaceID *string `json:"workspaceId,omitempty"`
   236  	// CreationTime - READ-ONLY; The creation time for this workspace resource.
   237  	CreationTime *string `json:"creationTime,omitempty"`
   238  	// StudioEndpoint - READ-ONLY; The regional endpoint for the machine learning studio service which hosts this workspace.
   239  	StudioEndpoint *string `json:"studioEndpoint,omitempty"`
   240  	// KeyVaultIdentifierID - The key vault identifier used for encrypted workspaces.
   241  	KeyVaultIdentifierID *string `json:"keyVaultIdentifierId,omitempty"`
   242  }
   243  
   244  // MarshalJSON is the custom marshaler for Properties.
   245  func (p Properties) MarshalJSON() ([]byte, error) {
   246  	objectMap := make(map[string]interface{})
   247  	if p.UserStorageAccountID != nil {
   248  		objectMap["userStorageAccountId"] = p.UserStorageAccountID
   249  	}
   250  	if p.OwnerEmail != nil {
   251  		objectMap["ownerEmail"] = p.OwnerEmail
   252  	}
   253  	if p.KeyVaultIdentifierID != nil {
   254  		objectMap["keyVaultIdentifierId"] = p.KeyVaultIdentifierID
   255  	}
   256  	return json.Marshal(objectMap)
   257  }
   258  
   259  // PropertiesUpdateParameters the parameters for updating the properties of a machine learning workspace.
   260  type PropertiesUpdateParameters struct {
   261  	// WorkspaceState - The current state of workspace resource. Possible values include: 'Deleted', 'Enabled', 'Disabled', 'Migrated', 'Updated', 'Registered', 'Unregistered'
   262  	WorkspaceState State `json:"workspaceState,omitempty"`
   263  	// KeyVaultIdentifierID - The key vault identifier used for encrypted workspaces.
   264  	KeyVaultIdentifierID *string `json:"keyVaultIdentifierId,omitempty"`
   265  	// Sku - The sku of the workspace.
   266  	Sku *Sku `json:"sku,omitempty"`
   267  }
   268  
   269  // Resource an Azure resource.
   270  type Resource struct {
   271  	// ID - READ-ONLY; The resource ID.
   272  	ID *string `json:"id,omitempty"`
   273  	// Name - READ-ONLY; The name of the resource.
   274  	Name *string `json:"name,omitempty"`
   275  	// Type - READ-ONLY; The type of the resource.
   276  	Type *string `json:"type,omitempty"`
   277  	// Location - The location of the resource. This cannot be changed after the resource is created.
   278  	Location *string `json:"location,omitempty"`
   279  	// Tags - The tags of the resource.
   280  	Tags map[string]*string `json:"tags"`
   281  	// Sku - The sku of the workspace.
   282  	Sku *Sku `json:"sku,omitempty"`
   283  }
   284  
   285  // MarshalJSON is the custom marshaler for Resource.
   286  func (r Resource) MarshalJSON() ([]byte, error) {
   287  	objectMap := make(map[string]interface{})
   288  	if r.Location != nil {
   289  		objectMap["location"] = r.Location
   290  	}
   291  	if r.Tags != nil {
   292  		objectMap["tags"] = r.Tags
   293  	}
   294  	if r.Sku != nil {
   295  		objectMap["sku"] = r.Sku
   296  	}
   297  	return json.Marshal(objectMap)
   298  }
   299  
   300  // Sku sku of the resource
   301  type Sku struct {
   302  	// Name - Name of the sku
   303  	Name *string `json:"name,omitempty"`
   304  	// Tier - Tier of the sku like Basic or Enterprise
   305  	Tier *string `json:"tier,omitempty"`
   306  }
   307  
   308  // UpdateParameters the parameters for updating a machine learning workspace.
   309  type UpdateParameters struct {
   310  	// Tags - The resource tags for the machine learning workspace.
   311  	Tags map[string]*string `json:"tags"`
   312  	// PropertiesUpdateParameters - The properties that the machine learning workspace will be updated with.
   313  	*PropertiesUpdateParameters `json:"properties,omitempty"`
   314  }
   315  
   316  // MarshalJSON is the custom marshaler for UpdateParameters.
   317  func (up UpdateParameters) MarshalJSON() ([]byte, error) {
   318  	objectMap := make(map[string]interface{})
   319  	if up.Tags != nil {
   320  		objectMap["tags"] = up.Tags
   321  	}
   322  	if up.PropertiesUpdateParameters != nil {
   323  		objectMap["properties"] = up.PropertiesUpdateParameters
   324  	}
   325  	return json.Marshal(objectMap)
   326  }
   327  
   328  // UnmarshalJSON is the custom unmarshaler for UpdateParameters struct.
   329  func (up *UpdateParameters) UnmarshalJSON(body []byte) error {
   330  	var m map[string]*json.RawMessage
   331  	err := json.Unmarshal(body, &m)
   332  	if err != nil {
   333  		return err
   334  	}
   335  	for k, v := range m {
   336  		switch k {
   337  		case "tags":
   338  			if v != nil {
   339  				var tags map[string]*string
   340  				err = json.Unmarshal(*v, &tags)
   341  				if err != nil {
   342  					return err
   343  				}
   344  				up.Tags = tags
   345  			}
   346  		case "properties":
   347  			if v != nil {
   348  				var propertiesUpdateParameters PropertiesUpdateParameters
   349  				err = json.Unmarshal(*v, &propertiesUpdateParameters)
   350  				if err != nil {
   351  					return err
   352  				}
   353  				up.PropertiesUpdateParameters = &propertiesUpdateParameters
   354  			}
   355  		}
   356  	}
   357  
   358  	return nil
   359  }
   360  
   361  // Workspace an object that represents a machine learning workspace.
   362  type Workspace struct {
   363  	autorest.Response `json:"-"`
   364  	// Properties - The properties of the machine learning workspace.
   365  	*Properties `json:"properties,omitempty"`
   366  	// ID - READ-ONLY; The resource ID.
   367  	ID *string `json:"id,omitempty"`
   368  	// Name - READ-ONLY; The name of the resource.
   369  	Name *string `json:"name,omitempty"`
   370  	// Type - READ-ONLY; The type of the resource.
   371  	Type *string `json:"type,omitempty"`
   372  	// Location - The location of the resource. This cannot be changed after the resource is created.
   373  	Location *string `json:"location,omitempty"`
   374  	// Tags - The tags of the resource.
   375  	Tags map[string]*string `json:"tags"`
   376  	// Sku - The sku of the workspace.
   377  	Sku *Sku `json:"sku,omitempty"`
   378  }
   379  
   380  // MarshalJSON is the custom marshaler for Workspace.
   381  func (w Workspace) MarshalJSON() ([]byte, error) {
   382  	objectMap := make(map[string]interface{})
   383  	if w.Properties != nil {
   384  		objectMap["properties"] = w.Properties
   385  	}
   386  	if w.Location != nil {
   387  		objectMap["location"] = w.Location
   388  	}
   389  	if w.Tags != nil {
   390  		objectMap["tags"] = w.Tags
   391  	}
   392  	if w.Sku != nil {
   393  		objectMap["sku"] = w.Sku
   394  	}
   395  	return json.Marshal(objectMap)
   396  }
   397  
   398  // UnmarshalJSON is the custom unmarshaler for Workspace struct.
   399  func (w *Workspace) UnmarshalJSON(body []byte) error {
   400  	var m map[string]*json.RawMessage
   401  	err := json.Unmarshal(body, &m)
   402  	if err != nil {
   403  		return err
   404  	}
   405  	for k, v := range m {
   406  		switch k {
   407  		case "properties":
   408  			if v != nil {
   409  				var properties Properties
   410  				err = json.Unmarshal(*v, &properties)
   411  				if err != nil {
   412  					return err
   413  				}
   414  				w.Properties = &properties
   415  			}
   416  		case "id":
   417  			if v != nil {
   418  				var ID string
   419  				err = json.Unmarshal(*v, &ID)
   420  				if err != nil {
   421  					return err
   422  				}
   423  				w.ID = &ID
   424  			}
   425  		case "name":
   426  			if v != nil {
   427  				var name string
   428  				err = json.Unmarshal(*v, &name)
   429  				if err != nil {
   430  					return err
   431  				}
   432  				w.Name = &name
   433  			}
   434  		case "type":
   435  			if v != nil {
   436  				var typeVar string
   437  				err = json.Unmarshal(*v, &typeVar)
   438  				if err != nil {
   439  					return err
   440  				}
   441  				w.Type = &typeVar
   442  			}
   443  		case "location":
   444  			if v != nil {
   445  				var location string
   446  				err = json.Unmarshal(*v, &location)
   447  				if err != nil {
   448  					return err
   449  				}
   450  				w.Location = &location
   451  			}
   452  		case "tags":
   453  			if v != nil {
   454  				var tags map[string]*string
   455  				err = json.Unmarshal(*v, &tags)
   456  				if err != nil {
   457  					return err
   458  				}
   459  				w.Tags = tags
   460  			}
   461  		case "sku":
   462  			if v != nil {
   463  				var sku Sku
   464  				err = json.Unmarshal(*v, &sku)
   465  				if err != nil {
   466  					return err
   467  				}
   468  				w.Sku = &sku
   469  			}
   470  		}
   471  	}
   472  
   473  	return nil
   474  }
   475  

View as plain text