...

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

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

View as plain text