...

Source file src/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2020-10-01/activitylogs/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2020-10-01/activitylogs

     1  package activitylogs
     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/monitor/mgmt/2020-10-01/activitylogs"
    21  
    22  // ActionGroupForActivityLogAlerts a pointer to an Azure Action Group.
    23  type ActionGroupForActivityLogAlerts struct {
    24  	// ActionGroupID - The resource ID of the Action Group. This cannot be null or empty.
    25  	ActionGroupID *string `json:"actionGroupId,omitempty"`
    26  	// WebhookProperties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload.
    27  	WebhookProperties map[string]*string `json:"webhookProperties"`
    28  }
    29  
    30  // MarshalJSON is the custom marshaler for ActionGroupForActivityLogAlerts.
    31  func (agfala ActionGroupForActivityLogAlerts) MarshalJSON() ([]byte, error) {
    32  	objectMap := make(map[string]interface{})
    33  	if agfala.ActionGroupID != nil {
    34  		objectMap["actionGroupId"] = agfala.ActionGroupID
    35  	}
    36  	if agfala.WebhookProperties != nil {
    37  		objectMap["webhookProperties"] = agfala.WebhookProperties
    38  	}
    39  	return json.Marshal(objectMap)
    40  }
    41  
    42  // ActionList a list of Activity Log Alert rule actions.
    43  type ActionList struct {
    44  	// ActionGroups - The list of the Action Groups.
    45  	ActionGroups *[]ActionGroupForActivityLogAlerts `json:"actionGroups,omitempty"`
    46  }
    47  
    48  // AlertResource an Activity Log Alert rule resource.
    49  type AlertResource struct {
    50  	autorest.Response `json:"-"`
    51  	// AlertRuleProperties - The Activity Log Alert rule properties of the resource.
    52  	*AlertRuleProperties `json:"properties,omitempty"`
    53  	// ID - READ-ONLY; Azure resource Id
    54  	ID *string `json:"id,omitempty"`
    55  	// Name - READ-ONLY; Azure resource name
    56  	Name *string `json:"name,omitempty"`
    57  	// Type - READ-ONLY; Azure resource type
    58  	Type *string `json:"type,omitempty"`
    59  	// Location - Resource location
    60  	Location *string `json:"location,omitempty"`
    61  	// Tags - Resource tags
    62  	Tags map[string]*string `json:"tags"`
    63  }
    64  
    65  // MarshalJSON is the custom marshaler for AlertResource.
    66  func (ar AlertResource) MarshalJSON() ([]byte, error) {
    67  	objectMap := make(map[string]interface{})
    68  	if ar.AlertRuleProperties != nil {
    69  		objectMap["properties"] = ar.AlertRuleProperties
    70  	}
    71  	if ar.Location != nil {
    72  		objectMap["location"] = ar.Location
    73  	}
    74  	if ar.Tags != nil {
    75  		objectMap["tags"] = ar.Tags
    76  	}
    77  	return json.Marshal(objectMap)
    78  }
    79  
    80  // UnmarshalJSON is the custom unmarshaler for AlertResource struct.
    81  func (ar *AlertResource) UnmarshalJSON(body []byte) error {
    82  	var m map[string]*json.RawMessage
    83  	err := json.Unmarshal(body, &m)
    84  	if err != nil {
    85  		return err
    86  	}
    87  	for k, v := range m {
    88  		switch k {
    89  		case "properties":
    90  			if v != nil {
    91  				var alertRuleProperties AlertRuleProperties
    92  				err = json.Unmarshal(*v, &alertRuleProperties)
    93  				if err != nil {
    94  					return err
    95  				}
    96  				ar.AlertRuleProperties = &alertRuleProperties
    97  			}
    98  		case "id":
    99  			if v != nil {
   100  				var ID string
   101  				err = json.Unmarshal(*v, &ID)
   102  				if err != nil {
   103  					return err
   104  				}
   105  				ar.ID = &ID
   106  			}
   107  		case "name":
   108  			if v != nil {
   109  				var name string
   110  				err = json.Unmarshal(*v, &name)
   111  				if err != nil {
   112  					return err
   113  				}
   114  				ar.Name = &name
   115  			}
   116  		case "type":
   117  			if v != nil {
   118  				var typeVar string
   119  				err = json.Unmarshal(*v, &typeVar)
   120  				if err != nil {
   121  					return err
   122  				}
   123  				ar.Type = &typeVar
   124  			}
   125  		case "location":
   126  			if v != nil {
   127  				var location string
   128  				err = json.Unmarshal(*v, &location)
   129  				if err != nil {
   130  					return err
   131  				}
   132  				ar.Location = &location
   133  			}
   134  		case "tags":
   135  			if v != nil {
   136  				var tags map[string]*string
   137  				err = json.Unmarshal(*v, &tags)
   138  				if err != nil {
   139  					return err
   140  				}
   141  				ar.Tags = tags
   142  			}
   143  		}
   144  	}
   145  
   146  	return nil
   147  }
   148  
   149  // AlertRuleAllOfCondition an Activity Log Alert rule condition that is met when all its member conditions
   150  // are met.
   151  type AlertRuleAllOfCondition struct {
   152  	// AllOf - The list of Activity Log Alert rule conditions.
   153  	AllOf *[]AlertRuleAnyOfOrLeafCondition `json:"allOf,omitempty"`
   154  }
   155  
   156  // AlertRuleAnyOfOrLeafCondition an Activity Log Alert rule condition that is met when all its member
   157  // conditions are met.
   158  // Each condition can be of one of the following types:
   159  // __Important__: Each type has its unique subset of properties. Properties from different types CANNOT
   160  // exist in one condition.
   161  // * __Leaf Condition -__ must contain 'field' and either 'equals' or 'containsAny'.
   162  // _Please note, 'anyOf' should __not__ be set in a Leaf Condition._
   163  // * __AnyOf Condition -__ must contain __only__ 'anyOf' (which is an array of Leaf Conditions).
   164  // _Please note, 'field', 'equals' and 'containsAny' should __not__ be set in an AnyOf Condition._
   165  type AlertRuleAnyOfOrLeafCondition struct {
   166  	// AnyOf - An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met.
   167  	AnyOf *[]AlertRuleLeafCondition `json:"anyOf,omitempty"`
   168  	// Field - The name of the Activity Log event's field that this condition will examine.
   169  	// The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'.
   170  	Field *string `json:"field,omitempty"`
   171  	// Equals - The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met.
   172  	Equals *string `json:"equals,omitempty"`
   173  	// ContainsAny - The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
   174  	ContainsAny *[]string `json:"containsAny,omitempty"`
   175  }
   176  
   177  // AlertRuleLeafCondition an Activity Log Alert rule condition that is met by comparing the field and value
   178  // of an Activity Log event.
   179  // This condition must contain 'field' and either 'equals' or 'containsAny'.
   180  type AlertRuleLeafCondition struct {
   181  	// Field - The name of the Activity Log event's field that this condition will examine.
   182  	// The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'.
   183  	Field *string `json:"field,omitempty"`
   184  	// Equals - The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met.
   185  	Equals *string `json:"equals,omitempty"`
   186  	// ContainsAny - The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
   187  	ContainsAny *[]string `json:"containsAny,omitempty"`
   188  }
   189  
   190  // AlertRuleList a list of Activity Log Alert rules.
   191  type AlertRuleList struct {
   192  	autorest.Response `json:"-"`
   193  	// Value - The list of Activity Log Alert rules.
   194  	Value *[]AlertResource `json:"value,omitempty"`
   195  	// NextLink - Provides the link to retrieve the next set of elements.
   196  	NextLink *string `json:"nextLink,omitempty"`
   197  }
   198  
   199  // AlertRuleListIterator provides access to a complete listing of AlertResource values.
   200  type AlertRuleListIterator struct {
   201  	i    int
   202  	page AlertRuleListPage
   203  }
   204  
   205  // NextWithContext advances to the next value.  If there was an error making
   206  // the request the iterator does not advance and the error is returned.
   207  func (iter *AlertRuleListIterator) NextWithContext(ctx context.Context) (err error) {
   208  	if tracing.IsEnabled() {
   209  		ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleListIterator.NextWithContext")
   210  		defer func() {
   211  			sc := -1
   212  			if iter.Response().Response.Response != nil {
   213  				sc = iter.Response().Response.Response.StatusCode
   214  			}
   215  			tracing.EndSpan(ctx, sc, err)
   216  		}()
   217  	}
   218  	iter.i++
   219  	if iter.i < len(iter.page.Values()) {
   220  		return nil
   221  	}
   222  	err = iter.page.NextWithContext(ctx)
   223  	if err != nil {
   224  		iter.i--
   225  		return err
   226  	}
   227  	iter.i = 0
   228  	return nil
   229  }
   230  
   231  // Next advances to the next value.  If there was an error making
   232  // the request the iterator does not advance and the error is returned.
   233  // Deprecated: Use NextWithContext() instead.
   234  func (iter *AlertRuleListIterator) Next() error {
   235  	return iter.NextWithContext(context.Background())
   236  }
   237  
   238  // NotDone returns true if the enumeration should be started or is not yet complete.
   239  func (iter AlertRuleListIterator) NotDone() bool {
   240  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   241  }
   242  
   243  // Response returns the raw server response from the last page request.
   244  func (iter AlertRuleListIterator) Response() AlertRuleList {
   245  	return iter.page.Response()
   246  }
   247  
   248  // Value returns the current value or a zero-initialized value if the
   249  // iterator has advanced beyond the end of the collection.
   250  func (iter AlertRuleListIterator) Value() AlertResource {
   251  	if !iter.page.NotDone() {
   252  		return AlertResource{}
   253  	}
   254  	return iter.page.Values()[iter.i]
   255  }
   256  
   257  // Creates a new instance of the AlertRuleListIterator type.
   258  func NewAlertRuleListIterator(page AlertRuleListPage) AlertRuleListIterator {
   259  	return AlertRuleListIterator{page: page}
   260  }
   261  
   262  // IsEmpty returns true if the ListResult contains no values.
   263  func (arl AlertRuleList) IsEmpty() bool {
   264  	return arl.Value == nil || len(*arl.Value) == 0
   265  }
   266  
   267  // hasNextLink returns true if the NextLink is not empty.
   268  func (arl AlertRuleList) hasNextLink() bool {
   269  	return arl.NextLink != nil && len(*arl.NextLink) != 0
   270  }
   271  
   272  // alertRuleListPreparer prepares a request to retrieve the next set of results.
   273  // It returns nil if no more results exist.
   274  func (arl AlertRuleList) alertRuleListPreparer(ctx context.Context) (*http.Request, error) {
   275  	if !arl.hasNextLink() {
   276  		return nil, nil
   277  	}
   278  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   279  		autorest.AsJSON(),
   280  		autorest.AsGet(),
   281  		autorest.WithBaseURL(to.String(arl.NextLink)))
   282  }
   283  
   284  // AlertRuleListPage contains a page of AlertResource values.
   285  type AlertRuleListPage struct {
   286  	fn  func(context.Context, AlertRuleList) (AlertRuleList, error)
   287  	arl AlertRuleList
   288  }
   289  
   290  // NextWithContext advances to the next page of values.  If there was an error making
   291  // the request the page does not advance and the error is returned.
   292  func (page *AlertRuleListPage) NextWithContext(ctx context.Context) (err error) {
   293  	if tracing.IsEnabled() {
   294  		ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleListPage.NextWithContext")
   295  		defer func() {
   296  			sc := -1
   297  			if page.Response().Response.Response != nil {
   298  				sc = page.Response().Response.Response.StatusCode
   299  			}
   300  			tracing.EndSpan(ctx, sc, err)
   301  		}()
   302  	}
   303  	for {
   304  		next, err := page.fn(ctx, page.arl)
   305  		if err != nil {
   306  			return err
   307  		}
   308  		page.arl = next
   309  		if !next.hasNextLink() || !next.IsEmpty() {
   310  			break
   311  		}
   312  	}
   313  	return nil
   314  }
   315  
   316  // Next advances to the next page of values.  If there was an error making
   317  // the request the page does not advance and the error is returned.
   318  // Deprecated: Use NextWithContext() instead.
   319  func (page *AlertRuleListPage) Next() error {
   320  	return page.NextWithContext(context.Background())
   321  }
   322  
   323  // NotDone returns true if the page enumeration should be started or is not yet complete.
   324  func (page AlertRuleListPage) NotDone() bool {
   325  	return !page.arl.IsEmpty()
   326  }
   327  
   328  // Response returns the raw server response from the last page request.
   329  func (page AlertRuleListPage) Response() AlertRuleList {
   330  	return page.arl
   331  }
   332  
   333  // Values returns the slice of values for the current page or nil if there are no values.
   334  func (page AlertRuleListPage) Values() []AlertResource {
   335  	if page.arl.IsEmpty() {
   336  		return nil
   337  	}
   338  	return *page.arl.Value
   339  }
   340  
   341  // Creates a new instance of the AlertRuleListPage type.
   342  func NewAlertRuleListPage(cur AlertRuleList, getNextPage func(context.Context, AlertRuleList) (AlertRuleList, error)) AlertRuleListPage {
   343  	return AlertRuleListPage{
   344  		fn:  getNextPage,
   345  		arl: cur,
   346  	}
   347  }
   348  
   349  // AlertRulePatchObject an Activity Log Alert rule object for the body of patch operations.
   350  type AlertRulePatchObject struct {
   351  	// Tags - The resource tags
   352  	Tags map[string]*string `json:"tags"`
   353  	// AlertRulePatchProperties - The activity log alert settings for an update operation.
   354  	*AlertRulePatchProperties `json:"properties,omitempty"`
   355  }
   356  
   357  // MarshalJSON is the custom marshaler for AlertRulePatchObject.
   358  func (arpo AlertRulePatchObject) MarshalJSON() ([]byte, error) {
   359  	objectMap := make(map[string]interface{})
   360  	if arpo.Tags != nil {
   361  		objectMap["tags"] = arpo.Tags
   362  	}
   363  	if arpo.AlertRulePatchProperties != nil {
   364  		objectMap["properties"] = arpo.AlertRulePatchProperties
   365  	}
   366  	return json.Marshal(objectMap)
   367  }
   368  
   369  // UnmarshalJSON is the custom unmarshaler for AlertRulePatchObject struct.
   370  func (arpo *AlertRulePatchObject) UnmarshalJSON(body []byte) error {
   371  	var m map[string]*json.RawMessage
   372  	err := json.Unmarshal(body, &m)
   373  	if err != nil {
   374  		return err
   375  	}
   376  	for k, v := range m {
   377  		switch k {
   378  		case "tags":
   379  			if v != nil {
   380  				var tags map[string]*string
   381  				err = json.Unmarshal(*v, &tags)
   382  				if err != nil {
   383  					return err
   384  				}
   385  				arpo.Tags = tags
   386  			}
   387  		case "properties":
   388  			if v != nil {
   389  				var alertRulePatchProperties AlertRulePatchProperties
   390  				err = json.Unmarshal(*v, &alertRulePatchProperties)
   391  				if err != nil {
   392  					return err
   393  				}
   394  				arpo.AlertRulePatchProperties = &alertRulePatchProperties
   395  			}
   396  		}
   397  	}
   398  
   399  	return nil
   400  }
   401  
   402  // AlertRulePatchProperties an Activity Log Alert rule properties for patch operations.
   403  type AlertRulePatchProperties struct {
   404  	// Enabled - Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated.
   405  	Enabled *bool `json:"enabled,omitempty"`
   406  }
   407  
   408  // AlertRuleProperties an Azure Activity Log Alert rule.
   409  type AlertRuleProperties struct {
   410  	// Scopes - A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one item.
   411  	Scopes *[]string `json:"scopes,omitempty"`
   412  	// Condition - The condition that will cause this alert to activate.
   413  	Condition *AlertRuleAllOfCondition `json:"condition,omitempty"`
   414  	// Actions - The actions that will activate when the condition is met.
   415  	Actions *ActionList `json:"actions,omitempty"`
   416  	// Enabled - Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated.
   417  	Enabled *bool `json:"enabled,omitempty"`
   418  	// Description - A description of this Activity Log Alert rule.
   419  	Description *string `json:"description,omitempty"`
   420  }
   421  
   422  // AzureResource an azure resource object
   423  type AzureResource struct {
   424  	// ID - READ-ONLY; Azure resource Id
   425  	ID *string `json:"id,omitempty"`
   426  	// Name - READ-ONLY; Azure resource name
   427  	Name *string `json:"name,omitempty"`
   428  	// Type - READ-ONLY; Azure resource type
   429  	Type *string `json:"type,omitempty"`
   430  	// Location - Resource location
   431  	Location *string `json:"location,omitempty"`
   432  	// Tags - Resource tags
   433  	Tags map[string]*string `json:"tags"`
   434  }
   435  
   436  // MarshalJSON is the custom marshaler for AzureResource.
   437  func (ar AzureResource) MarshalJSON() ([]byte, error) {
   438  	objectMap := make(map[string]interface{})
   439  	if ar.Location != nil {
   440  		objectMap["location"] = ar.Location
   441  	}
   442  	if ar.Tags != nil {
   443  		objectMap["tags"] = ar.Tags
   444  	}
   445  	return json.Marshal(objectMap)
   446  }
   447  
   448  // ErrorResponse describes the format of Error response.
   449  type ErrorResponse struct {
   450  	// Code - Error code
   451  	Code *string `json:"code,omitempty"`
   452  	// Message - Error message indicating why the operation failed.
   453  	Message *string `json:"message,omitempty"`
   454  }
   455  
   456  // EventData the Azure event log entries are of type EventData
   457  type EventData struct {
   458  	// Authorization - READ-ONLY; The sender authorization information.
   459  	Authorization *SenderAuthorization `json:"authorization,omitempty"`
   460  	// Claims - READ-ONLY; key value pairs to identify ARM permissions.
   461  	Claims map[string]*string `json:"claims"`
   462  	// Caller - READ-ONLY; the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability.
   463  	Caller *string `json:"caller,omitempty"`
   464  	// Description - READ-ONLY; the description of the event.
   465  	Description *string `json:"description,omitempty"`
   466  	// ID - READ-ONLY; the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information.
   467  	ID *string `json:"id,omitempty"`
   468  	// EventDataID - READ-ONLY; the event data Id. This is a unique identifier for an event.
   469  	EventDataID *string `json:"eventDataId,omitempty"`
   470  	// CorrelationID - READ-ONLY; the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation.
   471  	CorrelationID *string `json:"correlationId,omitempty"`
   472  	// EventName - READ-ONLY; the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users.
   473  	EventName *LocalizableString `json:"eventName,omitempty"`
   474  	// Category - READ-ONLY; the event category.
   475  	Category *LocalizableString `json:"category,omitempty"`
   476  	// HTTPRequest - READ-ONLY; the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT).
   477  	HTTPRequest *HTTPRequestInfo `json:"httpRequest,omitempty"`
   478  	// Level - READ-ONLY; the event level. Possible values include: 'EventLevelCritical', 'EventLevelError', 'EventLevelWarning', 'EventLevelInformational', 'EventLevelVerbose'
   479  	Level EventLevel `json:"level,omitempty"`
   480  	// ResourceGroupName - READ-ONLY; the resource group name of the impacted resource.
   481  	ResourceGroupName *string `json:"resourceGroupName,omitempty"`
   482  	// ResourceProviderName - READ-ONLY; the resource provider name of the impacted resource.
   483  	ResourceProviderName *LocalizableString `json:"resourceProviderName,omitempty"`
   484  	// ResourceID - READ-ONLY; the resource uri that uniquely identifies the resource that caused this event.
   485  	ResourceID *string `json:"resourceId,omitempty"`
   486  	// ResourceType - READ-ONLY; the resource type
   487  	ResourceType *LocalizableString `json:"resourceType,omitempty"`
   488  	// OperationID - READ-ONLY; It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName.
   489  	OperationID *string `json:"operationId,omitempty"`
   490  	// OperationName - READ-ONLY; the operation name.
   491  	OperationName *LocalizableString `json:"operationName,omitempty"`
   492  	// Properties - READ-ONLY; the set of <Key, Value> pairs (usually a Dictionary<String, String>) that includes details about the event.
   493  	Properties map[string]*string `json:"properties"`
   494  	// Status - READ-ONLY; a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved.
   495  	Status *LocalizableString `json:"status,omitempty"`
   496  	// SubStatus - READ-ONLY; the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504)
   497  	SubStatus *LocalizableString `json:"subStatus,omitempty"`
   498  	// EventTimestamp - READ-ONLY; the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format.
   499  	EventTimestamp *date.Time `json:"eventTimestamp,omitempty"`
   500  	// SubmissionTimestamp - READ-ONLY; the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure.
   501  	SubmissionTimestamp *date.Time `json:"submissionTimestamp,omitempty"`
   502  	// SubscriptionID - READ-ONLY; the Azure subscription Id usually a GUID.
   503  	SubscriptionID *string `json:"subscriptionId,omitempty"`
   504  	// TenantID - READ-ONLY; the Azure tenant Id
   505  	TenantID *string `json:"tenantId,omitempty"`
   506  }
   507  
   508  // MarshalJSON is the custom marshaler for EventData.
   509  func (ed EventData) MarshalJSON() ([]byte, error) {
   510  	objectMap := make(map[string]interface{})
   511  	return json.Marshal(objectMap)
   512  }
   513  
   514  // EventDataCollection represents collection of events.
   515  type EventDataCollection struct {
   516  	autorest.Response `json:"-"`
   517  	// Value - this list that includes the Azure audit logs.
   518  	Value *[]EventData `json:"value,omitempty"`
   519  	// NextLink - Provides the link to retrieve the next set of events.
   520  	NextLink *string `json:"nextLink,omitempty"`
   521  }
   522  
   523  // EventDataCollectionIterator provides access to a complete listing of EventData values.
   524  type EventDataCollectionIterator struct {
   525  	i    int
   526  	page EventDataCollectionPage
   527  }
   528  
   529  // NextWithContext advances to the next value.  If there was an error making
   530  // the request the iterator does not advance and the error is returned.
   531  func (iter *EventDataCollectionIterator) NextWithContext(ctx context.Context) (err error) {
   532  	if tracing.IsEnabled() {
   533  		ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionIterator.NextWithContext")
   534  		defer func() {
   535  			sc := -1
   536  			if iter.Response().Response.Response != nil {
   537  				sc = iter.Response().Response.Response.StatusCode
   538  			}
   539  			tracing.EndSpan(ctx, sc, err)
   540  		}()
   541  	}
   542  	iter.i++
   543  	if iter.i < len(iter.page.Values()) {
   544  		return nil
   545  	}
   546  	err = iter.page.NextWithContext(ctx)
   547  	if err != nil {
   548  		iter.i--
   549  		return err
   550  	}
   551  	iter.i = 0
   552  	return nil
   553  }
   554  
   555  // Next advances to the next value.  If there was an error making
   556  // the request the iterator does not advance and the error is returned.
   557  // Deprecated: Use NextWithContext() instead.
   558  func (iter *EventDataCollectionIterator) Next() error {
   559  	return iter.NextWithContext(context.Background())
   560  }
   561  
   562  // NotDone returns true if the enumeration should be started or is not yet complete.
   563  func (iter EventDataCollectionIterator) NotDone() bool {
   564  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   565  }
   566  
   567  // Response returns the raw server response from the last page request.
   568  func (iter EventDataCollectionIterator) Response() EventDataCollection {
   569  	return iter.page.Response()
   570  }
   571  
   572  // Value returns the current value or a zero-initialized value if the
   573  // iterator has advanced beyond the end of the collection.
   574  func (iter EventDataCollectionIterator) Value() EventData {
   575  	if !iter.page.NotDone() {
   576  		return EventData{}
   577  	}
   578  	return iter.page.Values()[iter.i]
   579  }
   580  
   581  // Creates a new instance of the EventDataCollectionIterator type.
   582  func NewEventDataCollectionIterator(page EventDataCollectionPage) EventDataCollectionIterator {
   583  	return EventDataCollectionIterator{page: page}
   584  }
   585  
   586  // IsEmpty returns true if the ListResult contains no values.
   587  func (edc EventDataCollection) IsEmpty() bool {
   588  	return edc.Value == nil || len(*edc.Value) == 0
   589  }
   590  
   591  // hasNextLink returns true if the NextLink is not empty.
   592  func (edc EventDataCollection) hasNextLink() bool {
   593  	return edc.NextLink != nil && len(*edc.NextLink) != 0
   594  }
   595  
   596  // eventDataCollectionPreparer prepares a request to retrieve the next set of results.
   597  // It returns nil if no more results exist.
   598  func (edc EventDataCollection) eventDataCollectionPreparer(ctx context.Context) (*http.Request, error) {
   599  	if !edc.hasNextLink() {
   600  		return nil, nil
   601  	}
   602  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   603  		autorest.AsJSON(),
   604  		autorest.AsGet(),
   605  		autorest.WithBaseURL(to.String(edc.NextLink)))
   606  }
   607  
   608  // EventDataCollectionPage contains a page of EventData values.
   609  type EventDataCollectionPage struct {
   610  	fn  func(context.Context, EventDataCollection) (EventDataCollection, error)
   611  	edc EventDataCollection
   612  }
   613  
   614  // NextWithContext advances to the next page of values.  If there was an error making
   615  // the request the page does not advance and the error is returned.
   616  func (page *EventDataCollectionPage) NextWithContext(ctx context.Context) (err error) {
   617  	if tracing.IsEnabled() {
   618  		ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionPage.NextWithContext")
   619  		defer func() {
   620  			sc := -1
   621  			if page.Response().Response.Response != nil {
   622  				sc = page.Response().Response.Response.StatusCode
   623  			}
   624  			tracing.EndSpan(ctx, sc, err)
   625  		}()
   626  	}
   627  	for {
   628  		next, err := page.fn(ctx, page.edc)
   629  		if err != nil {
   630  			return err
   631  		}
   632  		page.edc = next
   633  		if !next.hasNextLink() || !next.IsEmpty() {
   634  			break
   635  		}
   636  	}
   637  	return nil
   638  }
   639  
   640  // Next advances to the next page of values.  If there was an error making
   641  // the request the page does not advance and the error is returned.
   642  // Deprecated: Use NextWithContext() instead.
   643  func (page *EventDataCollectionPage) Next() error {
   644  	return page.NextWithContext(context.Background())
   645  }
   646  
   647  // NotDone returns true if the page enumeration should be started or is not yet complete.
   648  func (page EventDataCollectionPage) NotDone() bool {
   649  	return !page.edc.IsEmpty()
   650  }
   651  
   652  // Response returns the raw server response from the last page request.
   653  func (page EventDataCollectionPage) Response() EventDataCollection {
   654  	return page.edc
   655  }
   656  
   657  // Values returns the slice of values for the current page or nil if there are no values.
   658  func (page EventDataCollectionPage) Values() []EventData {
   659  	if page.edc.IsEmpty() {
   660  		return nil
   661  	}
   662  	return *page.edc.Value
   663  }
   664  
   665  // Creates a new instance of the EventDataCollectionPage type.
   666  func NewEventDataCollectionPage(cur EventDataCollection, getNextPage func(context.Context, EventDataCollection) (EventDataCollection, error)) EventDataCollectionPage {
   667  	return EventDataCollectionPage{
   668  		fn:  getNextPage,
   669  		edc: cur,
   670  	}
   671  }
   672  
   673  // HTTPRequestInfo the Http request info.
   674  type HTTPRequestInfo struct {
   675  	// ClientRequestID - the client request id.
   676  	ClientRequestID *string `json:"clientRequestId,omitempty"`
   677  	// ClientIPAddress - the client Ip Address
   678  	ClientIPAddress *string `json:"clientIpAddress,omitempty"`
   679  	// Method - the Http request method.
   680  	Method *string `json:"method,omitempty"`
   681  	// URI - the Uri.
   682  	URI *string `json:"uri,omitempty"`
   683  }
   684  
   685  // LocalizableString the localizable string class.
   686  type LocalizableString struct {
   687  	// Value - the invariant value.
   688  	Value *string `json:"value,omitempty"`
   689  	// LocalizedValue - the locale specific value.
   690  	LocalizedValue *string `json:"localizedValue,omitempty"`
   691  }
   692  
   693  // SenderAuthorization the authorization used by the user who has performed the operation that led to this
   694  // event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and
   695  // the 'scope'
   696  type SenderAuthorization struct {
   697  	// Action - the permissible actions. For instance: microsoft.support/supporttickets/write
   698  	Action *string `json:"action,omitempty"`
   699  	// Role - the role of the user. For instance: Subscription Admin
   700  	Role *string `json:"role,omitempty"`
   701  	// Scope - the scope.
   702  	Scope *string `json:"scope,omitempty"`
   703  }
   704  

View as plain text