...

Source file src/github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2021-08-01/scheduledqueryrules/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2021-08-01/scheduledqueryrules

     1  package scheduledqueryrules
     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/2021-08-01/scheduledqueryrules"
    21  
    22  // Actions actions to invoke when the alert fires.
    23  type Actions struct {
    24  	// ActionGroups - Action Group resource Ids to invoke when the alert fires.
    25  	ActionGroups *[]string `json:"actionGroups,omitempty"`
    26  	// CustomProperties - The properties of an alert payload.
    27  	CustomProperties map[string]*string `json:"customProperties"`
    28  }
    29  
    30  // MarshalJSON is the custom marshaler for Actions.
    31  func (a Actions) MarshalJSON() ([]byte, error) {
    32  	objectMap := make(map[string]interface{})
    33  	if a.ActionGroups != nil {
    34  		objectMap["actionGroups"] = a.ActionGroups
    35  	}
    36  	if a.CustomProperties != nil {
    37  		objectMap["customProperties"] = a.CustomProperties
    38  	}
    39  	return json.Marshal(objectMap)
    40  }
    41  
    42  // AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag.
    43  type AzureEntityResource struct {
    44  	// Etag - READ-ONLY; Resource Etag.
    45  	Etag *string `json:"etag,omitempty"`
    46  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
    47  	ID *string `json:"id,omitempty"`
    48  	// Name - READ-ONLY; The name of the resource
    49  	Name *string `json:"name,omitempty"`
    50  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
    51  	Type *string `json:"type,omitempty"`
    52  }
    53  
    54  // MarshalJSON is the custom marshaler for AzureEntityResource.
    55  func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
    56  	objectMap := make(map[string]interface{})
    57  	return json.Marshal(objectMap)
    58  }
    59  
    60  // Condition a condition of the scheduled query rule.
    61  type Condition struct {
    62  	// Query - Log query alert
    63  	Query *string `json:"query,omitempty"`
    64  	// TimeAggregation - Aggregation type. Relevant and required only for rules of the kind LogAlert. Possible values include: 'TimeAggregationCount', 'TimeAggregationAverage', 'TimeAggregationMinimum', 'TimeAggregationMaximum', 'TimeAggregationTotal'
    65  	TimeAggregation TimeAggregation `json:"timeAggregation,omitempty"`
    66  	// MetricMeasureColumn - The column containing the metric measure number. Relevant only for rules of the kind LogAlert.
    67  	MetricMeasureColumn *string `json:"metricMeasureColumn,omitempty"`
    68  	// ResourceIDColumn - The column containing the resource id. The content of the column must be a uri formatted as resource id. Relevant only for rules of the kind LogAlert.
    69  	ResourceIDColumn *string `json:"resourceIdColumn,omitempty"`
    70  	// Dimensions - List of Dimensions conditions
    71  	Dimensions *[]Dimension `json:"dimensions,omitempty"`
    72  	// Operator - The criteria operator. Relevant and required only for rules of the kind LogAlert. Possible values include: 'ConditionOperatorEquals', 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual'
    73  	Operator ConditionOperator `json:"operator,omitempty"`
    74  	// Threshold - the criteria threshold value that activates the alert. Relevant and required only for rules of the kind LogAlert.
    75  	Threshold *float64 `json:"threshold,omitempty"`
    76  	// FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. Relevant only for rules of the kind LogAlert.
    77  	FailingPeriods *ConditionFailingPeriods `json:"failingPeriods,omitempty"`
    78  	// MetricName - The name of the metric to be sent. Relevant and required only for rules of the kind LogToMetric.
    79  	MetricName *string `json:"metricName,omitempty"`
    80  }
    81  
    82  // ConditionFailingPeriods the minimum number of violations required within the selected lookback time
    83  // window required to raise an alert. Relevant only for rules of the kind LogAlert.
    84  type ConditionFailingPeriods struct {
    85  	// NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. Default value is 1
    86  	NumberOfEvaluationPeriods *int64 `json:"numberOfEvaluationPeriods,omitempty"`
    87  	// MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1
    88  	MinFailingPeriodsToAlert *int64 `json:"minFailingPeriodsToAlert,omitempty"`
    89  }
    90  
    91  // Criteria the rule criteria that defines the conditions of the scheduled query rule.
    92  type Criteria struct {
    93  	// AllOf - A list of conditions to evaluate against the specified scopes
    94  	AllOf *[]Condition `json:"allOf,omitempty"`
    95  }
    96  
    97  // Dimension dimension splitting and filtering definition
    98  type Dimension struct {
    99  	// Name - Name of the dimension
   100  	Name *string `json:"name,omitempty"`
   101  	// Operator - Operator for dimension values. Possible values include: 'DimensionOperatorInclude', 'DimensionOperatorExclude'
   102  	Operator DimensionOperator `json:"operator,omitempty"`
   103  	// Values - List of dimension values
   104  	Values *[]string `json:"values,omitempty"`
   105  }
   106  
   107  // ErrorAdditionalInfo the resource management error additional info.
   108  type ErrorAdditionalInfo struct {
   109  	// Type - READ-ONLY; The additional info type.
   110  	Type *string `json:"type,omitempty"`
   111  	// Info - READ-ONLY; The additional info.
   112  	Info interface{} `json:"info,omitempty"`
   113  }
   114  
   115  // MarshalJSON is the custom marshaler for ErrorAdditionalInfo.
   116  func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
   117  	objectMap := make(map[string]interface{})
   118  	return json.Marshal(objectMap)
   119  }
   120  
   121  // ErrorContract describes the format of Error response.
   122  type ErrorContract struct {
   123  	// Error - The error details.
   124  	Error *ErrorResponse `json:"error,omitempty"`
   125  }
   126  
   127  // ErrorResponse common error response for all Azure Resource Manager APIs to return error details for
   128  // failed operations. (This also follows the OData error response format.)
   129  type ErrorResponse struct {
   130  	// Code - READ-ONLY; The error code.
   131  	Code *string `json:"code,omitempty"`
   132  	// Message - READ-ONLY; The error message.
   133  	Message *string `json:"message,omitempty"`
   134  	// Target - READ-ONLY; The error target.
   135  	Target *string `json:"target,omitempty"`
   136  	// Details - READ-ONLY; The error details.
   137  	Details *[]ErrorResponse `json:"details,omitempty"`
   138  	// AdditionalInfo - READ-ONLY; The error additional info.
   139  	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
   140  }
   141  
   142  // MarshalJSON is the custom marshaler for ErrorResponse.
   143  func (er ErrorResponse) MarshalJSON() ([]byte, error) {
   144  	objectMap := make(map[string]interface{})
   145  	return json.Marshal(objectMap)
   146  }
   147  
   148  // Properties scheduled query rule Definition
   149  type Properties struct {
   150  	// CreatedWithAPIVersion - READ-ONLY; The api-version used when creating this alert rule
   151  	CreatedWithAPIVersion *string `json:"createdWithApiVersion,omitempty"`
   152  	// IsLegacyLogAnalyticsRule - READ-ONLY; True if alert rule is legacy Log Analytic rule
   153  	IsLegacyLogAnalyticsRule *bool `json:"isLegacyLogAnalyticsRule,omitempty"`
   154  	// Description - The description of the scheduled query rule.
   155  	Description *string `json:"description,omitempty"`
   156  	// DisplayName - The display name of the alert rule
   157  	DisplayName *string `json:"displayName,omitempty"`
   158  	// Severity - Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for rules of the kind LogAlert.
   159  	Severity *int64 `json:"severity,omitempty"`
   160  	// Enabled - The flag which indicates whether this scheduled query rule is enabled. Value should be true or false
   161  	Enabled *bool `json:"enabled,omitempty"`
   162  	// Scopes - The list of resource id's that this scheduled query rule is scoped to.
   163  	Scopes *[]string `json:"scopes,omitempty"`
   164  	// EvaluationFrequency - How often the scheduled query rule is evaluated represented in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.
   165  	EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
   166  	// WindowSize - The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.
   167  	WindowSize *string `json:"windowSize,omitempty"`
   168  	// OverrideQueryTimeRange - If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.
   169  	OverrideQueryTimeRange *string `json:"overrideQueryTimeRange,omitempty"`
   170  	// TargetResourceTypes - List of resource type of the target resource(s) on which the alert is created/updated. For example if the scope is a resource group and targetResourceTypes is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert
   171  	TargetResourceTypes *[]string `json:"targetResourceTypes,omitempty"`
   172  	// Criteria - The rule criteria that defines the conditions of the scheduled query rule.
   173  	Criteria *Criteria `json:"criteria,omitempty"`
   174  	// MuteActionsDuration - Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. Relevant only for rules of the kind LogAlert.
   175  	MuteActionsDuration *string `json:"muteActionsDuration,omitempty"`
   176  	// Actions - Actions to invoke when the alert fires.
   177  	Actions *Actions `json:"actions,omitempty"`
   178  	// IsWorkspaceAlertsStorageConfigured - READ-ONLY; The flag which indicates whether this scheduled query rule has been configured to be stored in the customer's storage. The default is false.
   179  	IsWorkspaceAlertsStorageConfigured *bool `json:"isWorkspaceAlertsStorageConfigured,omitempty"`
   180  	// CheckWorkspaceAlertsStorageConfigured - The flag which indicates whether this scheduled query rule should be stored in the customer's storage. The default is false. Relevant only for rules of the kind LogAlert.
   181  	CheckWorkspaceAlertsStorageConfigured *bool `json:"checkWorkspaceAlertsStorageConfigured,omitempty"`
   182  	// SkipQueryValidation - The flag which indicates whether the provided query should be validated or not. The default is false. Relevant only for rules of the kind LogAlert.
   183  	SkipQueryValidation *bool `json:"skipQueryValidation,omitempty"`
   184  	// AutoMitigate - The flag that indicates whether the alert should be automatically resolved or not. The default is true. Relevant only for rules of the kind LogAlert.
   185  	AutoMitigate *bool `json:"autoMitigate,omitempty"`
   186  }
   187  
   188  // MarshalJSON is the custom marshaler for Properties.
   189  func (p Properties) MarshalJSON() ([]byte, error) {
   190  	objectMap := make(map[string]interface{})
   191  	if p.Description != nil {
   192  		objectMap["description"] = p.Description
   193  	}
   194  	if p.DisplayName != nil {
   195  		objectMap["displayName"] = p.DisplayName
   196  	}
   197  	if p.Severity != nil {
   198  		objectMap["severity"] = p.Severity
   199  	}
   200  	if p.Enabled != nil {
   201  		objectMap["enabled"] = p.Enabled
   202  	}
   203  	if p.Scopes != nil {
   204  		objectMap["scopes"] = p.Scopes
   205  	}
   206  	if p.EvaluationFrequency != nil {
   207  		objectMap["evaluationFrequency"] = p.EvaluationFrequency
   208  	}
   209  	if p.WindowSize != nil {
   210  		objectMap["windowSize"] = p.WindowSize
   211  	}
   212  	if p.OverrideQueryTimeRange != nil {
   213  		objectMap["overrideQueryTimeRange"] = p.OverrideQueryTimeRange
   214  	}
   215  	if p.TargetResourceTypes != nil {
   216  		objectMap["targetResourceTypes"] = p.TargetResourceTypes
   217  	}
   218  	if p.Criteria != nil {
   219  		objectMap["criteria"] = p.Criteria
   220  	}
   221  	if p.MuteActionsDuration != nil {
   222  		objectMap["muteActionsDuration"] = p.MuteActionsDuration
   223  	}
   224  	if p.Actions != nil {
   225  		objectMap["actions"] = p.Actions
   226  	}
   227  	if p.CheckWorkspaceAlertsStorageConfigured != nil {
   228  		objectMap["checkWorkspaceAlertsStorageConfigured"] = p.CheckWorkspaceAlertsStorageConfigured
   229  	}
   230  	if p.SkipQueryValidation != nil {
   231  		objectMap["skipQueryValidation"] = p.SkipQueryValidation
   232  	}
   233  	if p.AutoMitigate != nil {
   234  		objectMap["autoMitigate"] = p.AutoMitigate
   235  	}
   236  	return json.Marshal(objectMap)
   237  }
   238  
   239  // ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not
   240  // have tags and a location
   241  type ProxyResource struct {
   242  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   243  	ID *string `json:"id,omitempty"`
   244  	// Name - READ-ONLY; The name of the resource
   245  	Name *string `json:"name,omitempty"`
   246  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   247  	Type *string `json:"type,omitempty"`
   248  }
   249  
   250  // MarshalJSON is the custom marshaler for ProxyResource.
   251  func (pr ProxyResource) MarshalJSON() ([]byte, error) {
   252  	objectMap := make(map[string]interface{})
   253  	return json.Marshal(objectMap)
   254  }
   255  
   256  // Resource common fields that are returned in the response for all Azure Resource Manager resources
   257  type Resource struct {
   258  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   259  	ID *string `json:"id,omitempty"`
   260  	// Name - READ-ONLY; The name of the resource
   261  	Name *string `json:"name,omitempty"`
   262  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   263  	Type *string `json:"type,omitempty"`
   264  }
   265  
   266  // MarshalJSON is the custom marshaler for Resource.
   267  func (r Resource) MarshalJSON() ([]byte, error) {
   268  	objectMap := make(map[string]interface{})
   269  	return json.Marshal(objectMap)
   270  }
   271  
   272  // ResourceCollection represents a collection of scheduled query rule resources.
   273  type ResourceCollection struct {
   274  	autorest.Response `json:"-"`
   275  	// Value - The values for the scheduled query rule resources.
   276  	Value *[]ResourceType `json:"value,omitempty"`
   277  	// NextLink - READ-ONLY; Provides the link to retrieve the next set of elements.
   278  	NextLink *string `json:"nextLink,omitempty"`
   279  }
   280  
   281  // MarshalJSON is the custom marshaler for ResourceCollection.
   282  func (rc ResourceCollection) MarshalJSON() ([]byte, error) {
   283  	objectMap := make(map[string]interface{})
   284  	if rc.Value != nil {
   285  		objectMap["value"] = rc.Value
   286  	}
   287  	return json.Marshal(objectMap)
   288  }
   289  
   290  // ResourceCollectionIterator provides access to a complete listing of ResourceType values.
   291  type ResourceCollectionIterator struct {
   292  	i    int
   293  	page ResourceCollectionPage
   294  }
   295  
   296  // NextWithContext advances to the next value.  If there was an error making
   297  // the request the iterator does not advance and the error is returned.
   298  func (iter *ResourceCollectionIterator) NextWithContext(ctx context.Context) (err error) {
   299  	if tracing.IsEnabled() {
   300  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceCollectionIterator.NextWithContext")
   301  		defer func() {
   302  			sc := -1
   303  			if iter.Response().Response.Response != nil {
   304  				sc = iter.Response().Response.Response.StatusCode
   305  			}
   306  			tracing.EndSpan(ctx, sc, err)
   307  		}()
   308  	}
   309  	iter.i++
   310  	if iter.i < len(iter.page.Values()) {
   311  		return nil
   312  	}
   313  	err = iter.page.NextWithContext(ctx)
   314  	if err != nil {
   315  		iter.i--
   316  		return err
   317  	}
   318  	iter.i = 0
   319  	return nil
   320  }
   321  
   322  // Next advances to the next value.  If there was an error making
   323  // the request the iterator does not advance and the error is returned.
   324  // Deprecated: Use NextWithContext() instead.
   325  func (iter *ResourceCollectionIterator) Next() error {
   326  	return iter.NextWithContext(context.Background())
   327  }
   328  
   329  // NotDone returns true if the enumeration should be started or is not yet complete.
   330  func (iter ResourceCollectionIterator) NotDone() bool {
   331  	return iter.page.NotDone() && iter.i < len(iter.page.Values())
   332  }
   333  
   334  // Response returns the raw server response from the last page request.
   335  func (iter ResourceCollectionIterator) Response() ResourceCollection {
   336  	return iter.page.Response()
   337  }
   338  
   339  // Value returns the current value or a zero-initialized value if the
   340  // iterator has advanced beyond the end of the collection.
   341  func (iter ResourceCollectionIterator) Value() ResourceType {
   342  	if !iter.page.NotDone() {
   343  		return ResourceType{}
   344  	}
   345  	return iter.page.Values()[iter.i]
   346  }
   347  
   348  // Creates a new instance of the ResourceCollectionIterator type.
   349  func NewResourceCollectionIterator(page ResourceCollectionPage) ResourceCollectionIterator {
   350  	return ResourceCollectionIterator{page: page}
   351  }
   352  
   353  // IsEmpty returns true if the ListResult contains no values.
   354  func (rc ResourceCollection) IsEmpty() bool {
   355  	return rc.Value == nil || len(*rc.Value) == 0
   356  }
   357  
   358  // hasNextLink returns true if the NextLink is not empty.
   359  func (rc ResourceCollection) hasNextLink() bool {
   360  	return rc.NextLink != nil && len(*rc.NextLink) != 0
   361  }
   362  
   363  // resourceCollectionPreparer prepares a request to retrieve the next set of results.
   364  // It returns nil if no more results exist.
   365  func (rc ResourceCollection) resourceCollectionPreparer(ctx context.Context) (*http.Request, error) {
   366  	if !rc.hasNextLink() {
   367  		return nil, nil
   368  	}
   369  	return autorest.Prepare((&http.Request{}).WithContext(ctx),
   370  		autorest.AsJSON(),
   371  		autorest.AsGet(),
   372  		autorest.WithBaseURL(to.String(rc.NextLink)))
   373  }
   374  
   375  // ResourceCollectionPage contains a page of ResourceType values.
   376  type ResourceCollectionPage struct {
   377  	fn func(context.Context, ResourceCollection) (ResourceCollection, error)
   378  	rc ResourceCollection
   379  }
   380  
   381  // NextWithContext advances to the next page of values.  If there was an error making
   382  // the request the page does not advance and the error is returned.
   383  func (page *ResourceCollectionPage) NextWithContext(ctx context.Context) (err error) {
   384  	if tracing.IsEnabled() {
   385  		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceCollectionPage.NextWithContext")
   386  		defer func() {
   387  			sc := -1
   388  			if page.Response().Response.Response != nil {
   389  				sc = page.Response().Response.Response.StatusCode
   390  			}
   391  			tracing.EndSpan(ctx, sc, err)
   392  		}()
   393  	}
   394  	for {
   395  		next, err := page.fn(ctx, page.rc)
   396  		if err != nil {
   397  			return err
   398  		}
   399  		page.rc = next
   400  		if !next.hasNextLink() || !next.IsEmpty() {
   401  			break
   402  		}
   403  	}
   404  	return nil
   405  }
   406  
   407  // Next advances to the next page of values.  If there was an error making
   408  // the request the page does not advance and the error is returned.
   409  // Deprecated: Use NextWithContext() instead.
   410  func (page *ResourceCollectionPage) Next() error {
   411  	return page.NextWithContext(context.Background())
   412  }
   413  
   414  // NotDone returns true if the page enumeration should be started or is not yet complete.
   415  func (page ResourceCollectionPage) NotDone() bool {
   416  	return !page.rc.IsEmpty()
   417  }
   418  
   419  // Response returns the raw server response from the last page request.
   420  func (page ResourceCollectionPage) Response() ResourceCollection {
   421  	return page.rc
   422  }
   423  
   424  // Values returns the slice of values for the current page or nil if there are no values.
   425  func (page ResourceCollectionPage) Values() []ResourceType {
   426  	if page.rc.IsEmpty() {
   427  		return nil
   428  	}
   429  	return *page.rc.Value
   430  }
   431  
   432  // Creates a new instance of the ResourceCollectionPage type.
   433  func NewResourceCollectionPage(cur ResourceCollection, getNextPage func(context.Context, ResourceCollection) (ResourceCollection, error)) ResourceCollectionPage {
   434  	return ResourceCollectionPage{
   435  		fn: getNextPage,
   436  		rc: cur,
   437  	}
   438  }
   439  
   440  // ResourcePatch the scheduled query rule resource for patch operations.
   441  type ResourcePatch struct {
   442  	// Tags - Resource tags
   443  	Tags map[string]*string `json:"tags"`
   444  	// Properties - The scheduled query rule properties of the resource.
   445  	*Properties `json:"properties,omitempty"`
   446  }
   447  
   448  // MarshalJSON is the custom marshaler for ResourcePatch.
   449  func (rp ResourcePatch) MarshalJSON() ([]byte, error) {
   450  	objectMap := make(map[string]interface{})
   451  	if rp.Tags != nil {
   452  		objectMap["tags"] = rp.Tags
   453  	}
   454  	if rp.Properties != nil {
   455  		objectMap["properties"] = rp.Properties
   456  	}
   457  	return json.Marshal(objectMap)
   458  }
   459  
   460  // UnmarshalJSON is the custom unmarshaler for ResourcePatch struct.
   461  func (rp *ResourcePatch) UnmarshalJSON(body []byte) error {
   462  	var m map[string]*json.RawMessage
   463  	err := json.Unmarshal(body, &m)
   464  	if err != nil {
   465  		return err
   466  	}
   467  	for k, v := range m {
   468  		switch k {
   469  		case "tags":
   470  			if v != nil {
   471  				var tags map[string]*string
   472  				err = json.Unmarshal(*v, &tags)
   473  				if err != nil {
   474  					return err
   475  				}
   476  				rp.Tags = tags
   477  			}
   478  		case "properties":
   479  			if v != nil {
   480  				var properties Properties
   481  				err = json.Unmarshal(*v, &properties)
   482  				if err != nil {
   483  					return err
   484  				}
   485  				rp.Properties = &properties
   486  			}
   487  		}
   488  	}
   489  
   490  	return nil
   491  }
   492  
   493  // ResourceType the scheduled query rule resource.
   494  type ResourceType struct {
   495  	autorest.Response `json:"-"`
   496  	// Kind - Indicates the type of scheduled query rule. The default is LogAlert. Possible values include: 'KindLogAlert', 'KindLogToMetric'
   497  	Kind Kind `json:"kind,omitempty"`
   498  	// Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention.  Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields.
   499  	Etag *string `json:"etag,omitempty"`
   500  	// SystemData - READ-ONLY; SystemData of ScheduledQueryRule.
   501  	SystemData *SystemData `json:"systemData,omitempty"`
   502  	// Properties - The rule properties of the resource.
   503  	*Properties `json:"properties,omitempty"`
   504  	// Tags - Resource tags.
   505  	Tags map[string]*string `json:"tags"`
   506  	// Location - The geo-location where the resource lives
   507  	Location *string `json:"location,omitempty"`
   508  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   509  	ID *string `json:"id,omitempty"`
   510  	// Name - READ-ONLY; The name of the resource
   511  	Name *string `json:"name,omitempty"`
   512  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   513  	Type *string `json:"type,omitempty"`
   514  }
   515  
   516  // MarshalJSON is the custom marshaler for ResourceType.
   517  func (rt ResourceType) MarshalJSON() ([]byte, error) {
   518  	objectMap := make(map[string]interface{})
   519  	if rt.Kind != "" {
   520  		objectMap["kind"] = rt.Kind
   521  	}
   522  	if rt.Properties != nil {
   523  		objectMap["properties"] = rt.Properties
   524  	}
   525  	if rt.Tags != nil {
   526  		objectMap["tags"] = rt.Tags
   527  	}
   528  	if rt.Location != nil {
   529  		objectMap["location"] = rt.Location
   530  	}
   531  	return json.Marshal(objectMap)
   532  }
   533  
   534  // UnmarshalJSON is the custom unmarshaler for ResourceType struct.
   535  func (rt *ResourceType) UnmarshalJSON(body []byte) error {
   536  	var m map[string]*json.RawMessage
   537  	err := json.Unmarshal(body, &m)
   538  	if err != nil {
   539  		return err
   540  	}
   541  	for k, v := range m {
   542  		switch k {
   543  		case "kind":
   544  			if v != nil {
   545  				var kind Kind
   546  				err = json.Unmarshal(*v, &kind)
   547  				if err != nil {
   548  					return err
   549  				}
   550  				rt.Kind = kind
   551  			}
   552  		case "etag":
   553  			if v != nil {
   554  				var etag string
   555  				err = json.Unmarshal(*v, &etag)
   556  				if err != nil {
   557  					return err
   558  				}
   559  				rt.Etag = &etag
   560  			}
   561  		case "systemData":
   562  			if v != nil {
   563  				var systemData SystemData
   564  				err = json.Unmarshal(*v, &systemData)
   565  				if err != nil {
   566  					return err
   567  				}
   568  				rt.SystemData = &systemData
   569  			}
   570  		case "properties":
   571  			if v != nil {
   572  				var properties Properties
   573  				err = json.Unmarshal(*v, &properties)
   574  				if err != nil {
   575  					return err
   576  				}
   577  				rt.Properties = &properties
   578  			}
   579  		case "tags":
   580  			if v != nil {
   581  				var tags map[string]*string
   582  				err = json.Unmarshal(*v, &tags)
   583  				if err != nil {
   584  					return err
   585  				}
   586  				rt.Tags = tags
   587  			}
   588  		case "location":
   589  			if v != nil {
   590  				var location string
   591  				err = json.Unmarshal(*v, &location)
   592  				if err != nil {
   593  					return err
   594  				}
   595  				rt.Location = &location
   596  			}
   597  		case "id":
   598  			if v != nil {
   599  				var ID string
   600  				err = json.Unmarshal(*v, &ID)
   601  				if err != nil {
   602  					return err
   603  				}
   604  				rt.ID = &ID
   605  			}
   606  		case "name":
   607  			if v != nil {
   608  				var name string
   609  				err = json.Unmarshal(*v, &name)
   610  				if err != nil {
   611  					return err
   612  				}
   613  				rt.Name = &name
   614  			}
   615  		case "type":
   616  			if v != nil {
   617  				var typeVar string
   618  				err = json.Unmarshal(*v, &typeVar)
   619  				if err != nil {
   620  					return err
   621  				}
   622  				rt.Type = &typeVar
   623  			}
   624  		}
   625  	}
   626  
   627  	return nil
   628  }
   629  
   630  // SystemData metadata pertaining to creation and last modification of the resource.
   631  type SystemData struct {
   632  	// CreatedBy - The identity that created the resource.
   633  	CreatedBy *string `json:"createdBy,omitempty"`
   634  	// CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey'
   635  	CreatedByType CreatedByType `json:"createdByType,omitempty"`
   636  	// CreatedAt - The timestamp of resource creation (UTC).
   637  	CreatedAt *date.Time `json:"createdAt,omitempty"`
   638  	// LastModifiedBy - The identity that last modified the resource.
   639  	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
   640  	// LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey'
   641  	LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
   642  	// LastModifiedAt - The timestamp of resource last modification (UTC)
   643  	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
   644  }
   645  
   646  // TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource
   647  // which has 'tags' and a 'location'
   648  type TrackedResource struct {
   649  	// Tags - Resource tags.
   650  	Tags map[string]*string `json:"tags"`
   651  	// Location - The geo-location where the resource lives
   652  	Location *string `json:"location,omitempty"`
   653  	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
   654  	ID *string `json:"id,omitempty"`
   655  	// Name - READ-ONLY; The name of the resource
   656  	Name *string `json:"name,omitempty"`
   657  	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
   658  	Type *string `json:"type,omitempty"`
   659  }
   660  
   661  // MarshalJSON is the custom marshaler for TrackedResource.
   662  func (tr TrackedResource) MarshalJSON() ([]byte, error) {
   663  	objectMap := make(map[string]interface{})
   664  	if tr.Tags != nil {
   665  		objectMap["tags"] = tr.Tags
   666  	}
   667  	if tr.Location != nil {
   668  		objectMap["location"] = tr.Location
   669  	}
   670  	return json.Marshal(objectMap)
   671  }
   672  

View as plain text