...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2016-04-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/2016-04-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  }
   266  
   267  // Resource an Azure resource.
   268  type Resource struct {
   269  	// ID - READ-ONLY; The resource ID.
   270  	ID *string `json:"id,omitempty"`
   271  	// Name - READ-ONLY; The name of the resource.
   272  	Name *string `json:"name,omitempty"`
   273  	// Type - READ-ONLY; The type of the resource.
   274  	Type *string `json:"type,omitempty"`
   275  	// Location - The location of the resource. This cannot be changed after the resource is created.
   276  	Location *string `json:"location,omitempty"`
   277  	// Tags - The tags of the resource.
   278  	Tags map[string]*string `json:"tags"`
   279  }
   280  
   281  // MarshalJSON is the custom marshaler for Resource.
   282  func (r Resource) MarshalJSON() ([]byte, error) {
   283  	objectMap := make(map[string]interface{})
   284  	if r.Location != nil {
   285  		objectMap["location"] = r.Location
   286  	}
   287  	if r.Tags != nil {
   288  		objectMap["tags"] = r.Tags
   289  	}
   290  	return json.Marshal(objectMap)
   291  }
   292  
   293  // UpdateParameters the parameters for updating a machine learning workspace.
   294  type UpdateParameters struct {
   295  	// Tags - The resource tags for the machine learning workspace.
   296  	Tags map[string]*string `json:"tags"`
   297  	// PropertiesUpdateParameters - The properties that the machine learning workspace will be updated with.
   298  	*PropertiesUpdateParameters `json:"properties,omitempty"`
   299  }
   300  
   301  // MarshalJSON is the custom marshaler for UpdateParameters.
   302  func (up UpdateParameters) MarshalJSON() ([]byte, error) {
   303  	objectMap := make(map[string]interface{})
   304  	if up.Tags != nil {
   305  		objectMap["tags"] = up.Tags
   306  	}
   307  	if up.PropertiesUpdateParameters != nil {
   308  		objectMap["properties"] = up.PropertiesUpdateParameters
   309  	}
   310  	return json.Marshal(objectMap)
   311  }
   312  
   313  // UnmarshalJSON is the custom unmarshaler for UpdateParameters struct.
   314  func (up *UpdateParameters) UnmarshalJSON(body []byte) error {
   315  	var m map[string]*json.RawMessage
   316  	err := json.Unmarshal(body, &m)
   317  	if err != nil {
   318  		return err
   319  	}
   320  	for k, v := range m {
   321  		switch k {
   322  		case "tags":
   323  			if v != nil {
   324  				var tags map[string]*string
   325  				err = json.Unmarshal(*v, &tags)
   326  				if err != nil {
   327  					return err
   328  				}
   329  				up.Tags = tags
   330  			}
   331  		case "properties":
   332  			if v != nil {
   333  				var propertiesUpdateParameters PropertiesUpdateParameters
   334  				err = json.Unmarshal(*v, &propertiesUpdateParameters)
   335  				if err != nil {
   336  					return err
   337  				}
   338  				up.PropertiesUpdateParameters = &propertiesUpdateParameters
   339  			}
   340  		}
   341  	}
   342  
   343  	return nil
   344  }
   345  
   346  // Workspace an object that represents a machine learning workspace.
   347  type Workspace struct {
   348  	autorest.Response `json:"-"`
   349  	// Properties - The properties of the machine learning workspace.
   350  	*Properties `json:"properties,omitempty"`
   351  	// ID - READ-ONLY; The resource ID.
   352  	ID *string `json:"id,omitempty"`
   353  	// Name - READ-ONLY; The name of the resource.
   354  	Name *string `json:"name,omitempty"`
   355  	// Type - READ-ONLY; The type of the resource.
   356  	Type *string `json:"type,omitempty"`
   357  	// Location - The location of the resource. This cannot be changed after the resource is created.
   358  	Location *string `json:"location,omitempty"`
   359  	// Tags - The tags of the resource.
   360  	Tags map[string]*string `json:"tags"`
   361  }
   362  
   363  // MarshalJSON is the custom marshaler for Workspace.
   364  func (w Workspace) MarshalJSON() ([]byte, error) {
   365  	objectMap := make(map[string]interface{})
   366  	if w.Properties != nil {
   367  		objectMap["properties"] = w.Properties
   368  	}
   369  	if w.Location != nil {
   370  		objectMap["location"] = w.Location
   371  	}
   372  	if w.Tags != nil {
   373  		objectMap["tags"] = w.Tags
   374  	}
   375  	return json.Marshal(objectMap)
   376  }
   377  
   378  // UnmarshalJSON is the custom unmarshaler for Workspace struct.
   379  func (w *Workspace) UnmarshalJSON(body []byte) error {
   380  	var m map[string]*json.RawMessage
   381  	err := json.Unmarshal(body, &m)
   382  	if err != nil {
   383  		return err
   384  	}
   385  	for k, v := range m {
   386  		switch k {
   387  		case "properties":
   388  			if v != nil {
   389  				var properties Properties
   390  				err = json.Unmarshal(*v, &properties)
   391  				if err != nil {
   392  					return err
   393  				}
   394  				w.Properties = &properties
   395  			}
   396  		case "id":
   397  			if v != nil {
   398  				var ID string
   399  				err = json.Unmarshal(*v, &ID)
   400  				if err != nil {
   401  					return err
   402  				}
   403  				w.ID = &ID
   404  			}
   405  		case "name":
   406  			if v != nil {
   407  				var name string
   408  				err = json.Unmarshal(*v, &name)
   409  				if err != nil {
   410  					return err
   411  				}
   412  				w.Name = &name
   413  			}
   414  		case "type":
   415  			if v != nil {
   416  				var typeVar string
   417  				err = json.Unmarshal(*v, &typeVar)
   418  				if err != nil {
   419  					return err
   420  				}
   421  				w.Type = &typeVar
   422  			}
   423  		case "location":
   424  			if v != nil {
   425  				var location string
   426  				err = json.Unmarshal(*v, &location)
   427  				if err != nil {
   428  					return err
   429  				}
   430  				w.Location = &location
   431  			}
   432  		case "tags":
   433  			if v != nil {
   434  				var tags map[string]*string
   435  				err = json.Unmarshal(*v, &tags)
   436  				if err != nil {
   437  					return err
   438  				}
   439  				w.Tags = tags
   440  			}
   441  		}
   442  	}
   443  
   444  	return nil
   445  }
   446  

View as plain text