...

Source file src/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/locks/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/locks

     1  package locks
     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/date"
    14  	"github.com/Azure/go-autorest/autorest/to"
    15  	"github.com/Azure/go-autorest/tracing"
    16  	"net/http"
    17  )
    18  
    19  // The package's fully qualified name.
    20  const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/locks"
    21  
    22  // ErrorAdditionalInfo the resource management error additional info.
    23  type ErrorAdditionalInfo struct {
    24  	// Type - READ-ONLY; The additional info type.
    25  	Type *string `json:"type,omitempty"`
    26  	// Info - READ-ONLY; The additional info.
    27  	Info interface{} `json:"info,omitempty"`
    28  }
    29  
    30  // MarshalJSON is the custom marshaler for ErrorAdditionalInfo.
    31  func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
    32  	objectMap := make(map[string]interface{})
    33  	return json.Marshal(objectMap)
    34  }
    35  
    36  // ErrorDetail the error detail.
    37  type ErrorDetail struct {
    38  	// Code - READ-ONLY; The error code.
    39  	Code *string `json:"code,omitempty"`
    40  	// Message - READ-ONLY; The error message.
    41  	Message *string `json:"message,omitempty"`
    42  	// Target - READ-ONLY; The error target.
    43  	Target *string `json:"target,omitempty"`
    44  	// Details - READ-ONLY; The error details.
    45  	Details *[]ErrorDetail `json:"details,omitempty"`
    46  	// AdditionalInfo - READ-ONLY; The error additional info.
    47  	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
    48  }
    49  
    50  // MarshalJSON is the custom marshaler for ErrorDetail.
    51  func (ed ErrorDetail) MarshalJSON() ([]byte, error) {
    52  	objectMap := make(map[string]interface{})
    53  	return json.Marshal(objectMap)
    54  }
    55  
    56  // ErrorResponse common error response for all Azure Resource Manager APIs to return error details for
    57  // failed operations. (This also follows the OData error response format.).
    58  type ErrorResponse struct {
    59  	// Error - The error object.
    60  	Error *ErrorDetail `json:"error,omitempty"`
    61  }
    62  
    63  // ManagementLockListResult the list of locks.
    64  type ManagementLockListResult struct {
    65  	autorest.Response `json:"-"`
    66  	// Value - The list of locks.
    67  	Value *[]ManagementLockObject `json:"value,omitempty"`
    68  	// NextLink - The URL to use for getting the next set of results.
    69  	NextLink *string `json:"nextLink,omitempty"`
    70  }
    71  
    72  // ManagementLockListResultIterator provides access to a complete listing of ManagementLockObject values.
    73  type ManagementLockListResultIterator struct {
    74  	i    int
    75  	page ManagementLockListResultPage
    76  }
    77  
    78  // NextWithContext advances to the next value.  If there was an error making
    79  // the request the iterator does not advance and the error is returned.
    80  func (iter *ManagementLockListResultIterator) NextWithContext(ctx context.Context) (err error) {
    81  	if tracing.IsEnabled() {
    82  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultIterator.NextWithContext")
    83  		defer func() {
    84  			sc := -1
    85  			if iter.Response().Response.Response != nil {
    86  				sc = iter.Response().Response.Response.StatusCode
    87  			}
    88  			tracing.EndSpan(ctx, sc, err)
    89  		}()
    90  	}
    91  	iter.i++
    92  	if iter.i < len(iter.page.Values()) {
    93  		return nil
    94  	}
    95  	err = iter.page.NextWithContext(ctx)
    96  	if err != nil {
    97  		iter.i--
    98  		return err
    99  	}
   100  	iter.i = 0
   101  	return nil
   102  }
   103  
   104  // Next advances to the next value.  If there was an error making
   105  // the request the iterator does not advance and the error is returned.
   106  // Deprecated: Use NextWithContext() instead.
   107  func (iter *ManagementLockListResultIterator) Next() error {
   108  	return iter.NextWithContext(context.Background())
   109  }
   110  
   111  // NotDone returns true if the enumeration should be started or is not yet complete.
   112  func (iter ManagementLockListResultIterator) NotDone() bool {
   113  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   114  }
   115  
   116  // Response returns the raw server response from the last page request.
   117  func (iter ManagementLockListResultIterator) Response() ManagementLockListResult {
   118  	return iter.page.Response()
   119  }
   120  
   121  // Value returns the current value or a zero-initialized value if the
   122  // iterator has advanced beyond the end of the collection.
   123  func (iter ManagementLockListResultIterator) Value() ManagementLockObject {
   124  	if !iter.page.NotDone() {
   125  		return ManagementLockObject{}
   126  	}
   127  	return iter.page.Values()[iter.i]
   128  }
   129  
   130  // Creates a new instance of the ManagementLockListResultIterator type.
   131  func NewManagementLockListResultIterator(page ManagementLockListResultPage) ManagementLockListResultIterator {
   132  	return ManagementLockListResultIterator{page: page}
   133  }
   134  
   135  // IsEmpty returns true if the ListResult contains no values.
   136  func (mllr ManagementLockListResult) IsEmpty() bool {
   137  	return mllr.Value == nil || len(*mllr.Value) == 0
   138  }
   139  
   140  // hasNextLink returns true if the NextLink is not empty.
   141  func (mllr ManagementLockListResult) hasNextLink() bool {
   142  	return mllr.NextLink != nil && len(*mllr.NextLink) != 0
   143  }
   144  
   145  // managementLockListResultPreparer prepares a request to retrieve the next set of results.
   146  // It returns nil if no more results exist.
   147  func (mllr ManagementLockListResult) managementLockListResultPreparer(ctx context.Context) (*http.Request, error) {
   148  	if !mllr.hasNextLink() {
   149  		return nil, nil
   150  	}
   151  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   152  		autorest.AsJSON(),
   153  		autorest.AsGet(),
   154  		autorest.WithBaseURL(to.String(mllr.NextLink)))
   155  }
   156  
   157  // ManagementLockListResultPage contains a page of ManagementLockObject values.
   158  type ManagementLockListResultPage struct {
   159  	fn   func(context.Context, ManagementLockListResult) (ManagementLockListResult, error)
   160  	mllr ManagementLockListResult
   161  }
   162  
   163  // NextWithContext advances to the next page of values.  If there was an error making
   164  // the request the page does not advance and the error is returned.
   165  func (page *ManagementLockListResultPage) NextWithContext(ctx context.Context) (err error) {
   166  	if tracing.IsEnabled() {
   167  		ctx = tracing.StartSpan(ctx, fqdn+"/ManagementLockListResultPage.NextWithContext")
   168  		defer func() {
   169  			sc := -1
   170  			if page.Response().Response.Response != nil {
   171  				sc = page.Response().Response.Response.StatusCode
   172  			}
   173  			tracing.EndSpan(ctx, sc, err)
   174  		}()
   175  	}
   176  	for {
   177  		next, err := page.fn(ctx, page.mllr)
   178  		if err != nil {
   179  			return err
   180  		}
   181  		page.mllr = next
   182  		if !next.hasNextLink() || !next.IsEmpty() {
   183  			break
   184  		}
   185  	}
   186  	return nil
   187  }
   188  
   189  // Next advances to the next page of values.  If there was an error making
   190  // the request the page does not advance and the error is returned.
   191  // Deprecated: Use NextWithContext() instead.
   192  func (page *ManagementLockListResultPage) Next() error {
   193  	return page.NextWithContext(context.Background())
   194  }
   195  
   196  // NotDone returns true if the page enumeration should be started or is not yet complete.
   197  func (page ManagementLockListResultPage) NotDone() bool {
   198  	return !page.mllr.IsEmpty()
   199  }
   200  
   201  // Response returns the raw server response from the last page request.
   202  func (page ManagementLockListResultPage) Response() ManagementLockListResult {
   203  	return page.mllr
   204  }
   205  
   206  // Values returns the slice of values for the current page or nil if there are no values.
   207  func (page ManagementLockListResultPage) Values() []ManagementLockObject {
   208  	if page.mllr.IsEmpty() {
   209  		return nil
   210  	}
   211  	return *page.mllr.Value
   212  }
   213  
   214  // Creates a new instance of the ManagementLockListResultPage type.
   215  func NewManagementLockListResultPage(cur ManagementLockListResult, getNextPage func(context.Context, ManagementLockListResult) (ManagementLockListResult, error)) ManagementLockListResultPage {
   216  	return ManagementLockListResultPage{
   217  		fn:   getNextPage,
   218  		mllr: cur,
   219  	}
   220  }
   221  
   222  // ManagementLockObject the lock information.
   223  type ManagementLockObject struct {
   224  	autorest.Response `json:"-"`
   225  	// ManagementLockProperties - The properties of the lock.
   226  	*ManagementLockProperties `json:"properties,omitempty"`
   227  	// ID - READ-ONLY; The resource ID of the lock.
   228  	ID *string `json:"id,omitempty"`
   229  	// Type - READ-ONLY; The resource type of the lock - Microsoft.Authorization/locks.
   230  	Type *string `json:"type,omitempty"`
   231  	// Name - READ-ONLY; The name of the lock.
   232  	Name *string `json:"name,omitempty"`
   233  	// SystemData - READ-ONLY
   234  	SystemData *SystemData `json:"systemData,omitempty"`
   235  }
   236  
   237  // MarshalJSON is the custom marshaler for ManagementLockObject.
   238  func (mlo ManagementLockObject) MarshalJSON() ([]byte, error) {
   239  	objectMap := make(map[string]interface{})
   240  	if mlo.ManagementLockProperties != nil {
   241  		objectMap["properties"] = mlo.ManagementLockProperties
   242  	}
   243  	return json.Marshal(objectMap)
   244  }
   245  
   246  // UnmarshalJSON is the custom unmarshaler for ManagementLockObject struct.
   247  func (mlo *ManagementLockObject) UnmarshalJSON(body []byte) error {
   248  	var m map[string]*json.RawMessage
   249  	err := json.Unmarshal(body, &m)
   250  	if err != nil {
   251  		return err
   252  	}
   253  	for k, v := range m {
   254  		switch k {
   255  		case "properties":
   256  			if v != nil {
   257  				var managementLockProperties ManagementLockProperties
   258  				err = json.Unmarshal(*v, &managementLockProperties)
   259  				if err != nil {
   260  					return err
   261  				}
   262  				mlo.ManagementLockProperties = &managementLockProperties
   263  			}
   264  		case "id":
   265  			if v != nil {
   266  				var ID string
   267  				err = json.Unmarshal(*v, &ID)
   268  				if err != nil {
   269  					return err
   270  				}
   271  				mlo.ID = &ID
   272  			}
   273  		case "type":
   274  			if v != nil {
   275  				var typeVar string
   276  				err = json.Unmarshal(*v, &typeVar)
   277  				if err != nil {
   278  					return err
   279  				}
   280  				mlo.Type = &typeVar
   281  			}
   282  		case "name":
   283  			if v != nil {
   284  				var name string
   285  				err = json.Unmarshal(*v, &name)
   286  				if err != nil {
   287  					return err
   288  				}
   289  				mlo.Name = &name
   290  			}
   291  		case "systemData":
   292  			if v != nil {
   293  				var systemData SystemData
   294  				err = json.Unmarshal(*v, &systemData)
   295  				if err != nil {
   296  					return err
   297  				}
   298  				mlo.SystemData = &systemData
   299  			}
   300  		}
   301  	}
   302  
   303  	return nil
   304  }
   305  
   306  // ManagementLockOwner lock owner properties.
   307  type ManagementLockOwner struct {
   308  	// ApplicationID - The application ID of the lock owner.
   309  	ApplicationID *string `json:"applicationId,omitempty"`
   310  }
   311  
   312  // ManagementLockProperties the lock properties.
   313  type ManagementLockProperties struct {
   314  	// Level - The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. Possible values include: 'NotSpecified', 'CanNotDelete', 'ReadOnly'
   315  	Level LockLevel `json:"level,omitempty"`
   316  	// Notes - Notes about the lock. Maximum of 512 characters.
   317  	Notes *string `json:"notes,omitempty"`
   318  	// Owners - The owners of the lock.
   319  	Owners *[]ManagementLockOwner `json:"owners,omitempty"`
   320  }
   321  
   322  // Operation microsoft.Authorization operation
   323  type Operation struct {
   324  	// Name - Operation name: {provider}/{resource}/{operation}
   325  	Name *string `json:"name,omitempty"`
   326  	// Display - The object that represents the operation.
   327  	Display *OperationDisplay `json:"display,omitempty"`
   328  }
   329  
   330  // OperationDisplay the object that represents the operation.
   331  type OperationDisplay struct {
   332  	// Provider - Service provider: Microsoft.Authorization
   333  	Provider *string `json:"provider,omitempty"`
   334  	// Resource - Resource on which the operation is performed: Profile, endpoint, etc.
   335  	Resource *string `json:"resource,omitempty"`
   336  	// Operation - Operation type: Read, write, delete, etc.
   337  	Operation *string `json:"operation,omitempty"`
   338  }
   339  
   340  // OperationListResult result of the request to list Microsoft.Authorization operations. It contains a list
   341  // of operations and a URL link to get the next set of results.
   342  type OperationListResult struct {
   343  	autorest.Response `json:"-"`
   344  	// Value - List of Microsoft.Authorization operations.
   345  	Value *[]Operation `json:"value,omitempty"`
   346  	// NextLink - URL to get the next set of operation list results if there are any.
   347  	NextLink *string `json:"nextLink,omitempty"`
   348  }
   349  
   350  // OperationListResultIterator provides access to a complete listing of Operation values.
   351  type OperationListResultIterator struct {
   352  	i    int
   353  	page OperationListResultPage
   354  }
   355  
   356  // NextWithContext advances to the next value.  If there was an error making
   357  // the request the iterator does not advance and the error is returned.
   358  func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
   359  	if tracing.IsEnabled() {
   360  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
   361  		defer func() {
   362  			sc := -1
   363  			if iter.Response().Response.Response != nil {
   364  				sc = iter.Response().Response.Response.StatusCode
   365  			}
   366  			tracing.EndSpan(ctx, sc, err)
   367  		}()
   368  	}
   369  	iter.i++
   370  	if iter.i < len(iter.page.Values()) {
   371  		return nil
   372  	}
   373  	err = iter.page.NextWithContext(ctx)
   374  	if err != nil {
   375  		iter.i--
   376  		return err
   377  	}
   378  	iter.i = 0
   379  	return nil
   380  }
   381  
   382  // Next advances to the next value.  If there was an error making
   383  // the request the iterator does not advance and the error is returned.
   384  // Deprecated: Use NextWithContext() instead.
   385  func (iter *OperationListResultIterator) Next() error {
   386  	return iter.NextWithContext(context.Background())
   387  }
   388  
   389  // NotDone returns true if the enumeration should be started or is not yet complete.
   390  func (iter OperationListResultIterator) NotDone() bool {
   391  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   392  }
   393  
   394  // Response returns the raw server response from the last page request.
   395  func (iter OperationListResultIterator) Response() OperationListResult {
   396  	return iter.page.Response()
   397  }
   398  
   399  // Value returns the current value or a zero-initialized value if the
   400  // iterator has advanced beyond the end of the collection.
   401  func (iter OperationListResultIterator) Value() Operation {
   402  	if !iter.page.NotDone() {
   403  		return Operation{}
   404  	}
   405  	return iter.page.Values()[iter.i]
   406  }
   407  
   408  // Creates a new instance of the OperationListResultIterator type.
   409  func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
   410  	return OperationListResultIterator{page: page}
   411  }
   412  
   413  // IsEmpty returns true if the ListResult contains no values.
   414  func (olr OperationListResult) IsEmpty() bool {
   415  	return olr.Value == nil || len(*olr.Value) == 0
   416  }
   417  
   418  // hasNextLink returns true if the NextLink is not empty.
   419  func (olr OperationListResult) hasNextLink() bool {
   420  	return olr.NextLink != nil && len(*olr.NextLink) != 0
   421  }
   422  
   423  // operationListResultPreparer prepares a request to retrieve the next set of results.
   424  // It returns nil if no more results exist.
   425  func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
   426  	if !olr.hasNextLink() {
   427  		return nil, nil
   428  	}
   429  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   430  		autorest.AsJSON(),
   431  		autorest.AsGet(),
   432  		autorest.WithBaseURL(to.String(olr.NextLink)))
   433  }
   434  
   435  // OperationListResultPage contains a page of Operation values.
   436  type OperationListResultPage struct {
   437  	fn  func(context.Context, OperationListResult) (OperationListResult, error)
   438  	olr OperationListResult
   439  }
   440  
   441  // NextWithContext advances to the next page of values.  If there was an error making
   442  // the request the page does not advance and the error is returned.
   443  func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
   444  	if tracing.IsEnabled() {
   445  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
   446  		defer func() {
   447  			sc := -1
   448  			if page.Response().Response.Response != nil {
   449  				sc = page.Response().Response.Response.StatusCode
   450  			}
   451  			tracing.EndSpan(ctx, sc, err)
   452  		}()
   453  	}
   454  	for {
   455  		next, err := page.fn(ctx, page.olr)
   456  		if err != nil {
   457  			return err
   458  		}
   459  		page.olr = next
   460  		if !next.hasNextLink() || !next.IsEmpty() {
   461  			break
   462  		}
   463  	}
   464  	return nil
   465  }
   466  
   467  // Next advances to the next page of values.  If there was an error making
   468  // the request the page does not advance and the error is returned.
   469  // Deprecated: Use NextWithContext() instead.
   470  func (page *OperationListResultPage) Next() error {
   471  	return page.NextWithContext(context.Background())
   472  }
   473  
   474  // NotDone returns true if the page enumeration should be started or is not yet complete.
   475  func (page OperationListResultPage) NotDone() bool {
   476  	return !page.olr.IsEmpty()
   477  }
   478  
   479  // Response returns the raw server response from the last page request.
   480  func (page OperationListResultPage) Response() OperationListResult {
   481  	return page.olr
   482  }
   483  
   484  // Values returns the slice of values for the current page or nil if there are no values.
   485  func (page OperationListResultPage) Values() []Operation {
   486  	if page.olr.IsEmpty() {
   487  		return nil
   488  	}
   489  	return *page.olr.Value
   490  }
   491  
   492  // Creates a new instance of the OperationListResultPage type.
   493  func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
   494  	return OperationListResultPage{
   495  		fn:  getNextPage,
   496  		olr: cur,
   497  	}
   498  }
   499  
   500  // SystemData metadata pertaining to creation and last modification of the resource.
   501  type SystemData struct {
   502  	// CreatedBy - The identity that created the resource.
   503  	CreatedBy *string `json:"createdBy,omitempty"`
   504  	// CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key'
   505  	CreatedByType CreatedByType `json:"createdByType,omitempty"`
   506  	// CreatedAt - The timestamp of resource creation (UTC).
   507  	CreatedAt *date.Time `json:"createdAt,omitempty"`
   508  	// LastModifiedBy - The identity that last modified the resource.
   509  	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
   510  	// LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key'
   511  	LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
   512  	// LastModifiedAt - The timestamp of resource last modification (UTC)
   513  	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
   514  }
   515  

View as plain text