diff --git a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/models.go b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/models.go index 985a7a1f0cba..62220ea193d8 100644 --- a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/models.go +++ b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/models.go @@ -1199,11 +1199,12 @@ func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollect return MonitorsCollectionPage{fn: getNextPage} } -// NotificationSetting model for component. +// NotificationSetting model for NotificationSetting. type NotificationSetting struct { + autorest.Response `json:"-"` // Etag - For optimistic concurrency control. Etag *string `json:"etag,omitempty"` - // NotificationSettingProperties - Properties of the component. + // NotificationSettingProperties - Properties of Notification Settings *NotificationSettingProperties `json:"properties,omitempty"` // ID - Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string `json:"id,omitempty"` @@ -1296,17 +1297,16 @@ func (ns *NotificationSetting) UnmarshalJSON(body []byte) error { // NotificationSettingProperties model for properties of a NotificationSetting. type NotificationSettingProperties struct { - // ActionGroups - List of action group resource ids to be notified - ActionGroups *[]string `json:"actionGroups,omitempty"` + // ActionGroupResourceIds - List of action group resource ids to be notified + ActionGroupResourceIds *[]string `json:"actionGroupResourceIds,omitempty"` } // NotificationSettingsCollection model for collection of notificationSettings. type NotificationSettingsCollection struct { autorest.Response `json:"-"` + Value *[]NotificationSetting `json:"value,omitempty"` // NextLink - URL to the next set of results. NextLink *string `json:"nextLink,omitempty"` - // Value - Collection of components. - Value *[]NotificationSetting `json:"value,omitempty"` } // NotificationSettingsCollectionIterator provides access to a complete listing of NotificationSetting diff --git a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/notificationsettings.go b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/notificationsettings.go index 14165ba6d6df..2ef3d57d5d20 100644 --- a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/notificationsettings.go +++ b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/notificationsettings.go @@ -41,6 +41,98 @@ func NewNotificationSettingsClientWithBaseURI(baseURI string, subscriptionID str return NotificationSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} } +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result NotificationSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotificationSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationSettingName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/notificationSettings/{notificationSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotificationSettingsClient) GetResponder(resp *http.Response) (result NotificationSetting, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByResource sends the list by resource request. // Parameters: // resourceGroupName - the name of the resource group. The name is case insensitive. @@ -173,3 +265,98 @@ func (client NotificationSettingsClient) ListByResourceComplete(ctx context.Cont result.page, err = client.ListByResource(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, skiptoken) return } + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +// body - body of the NotificationSetting PUT object. +func (client NotificationSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, body NotificationSetting) (result NotificationSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client NotificationSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, body NotificationSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationSettingName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/notificationSettings/{notificationSettingName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client NotificationSettingsClient) UpdateResponder(resp *http.Response) (result NotificationSetting, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/workloadmonitorapi/interfaces.go b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/workloadmonitorapi/interfaces.go index 3be6de6b3237..7485472f8533 100644 --- a/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/workloadmonitorapi/interfaces.go +++ b/services/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor/workloadmonitorapi/interfaces.go @@ -50,7 +50,9 @@ var _ MonitorInstancesClientAPI = (*workloadmonitor.MonitorInstancesClient)(nil) // NotificationSettingsClientAPI contains the set of methods on the NotificationSettingsClient type. type NotificationSettingsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result workloadmonitor.NotificationSetting, err error) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result workloadmonitor.NotificationSettingsCollectionPage, err error) + Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSetting, err error) } var _ NotificationSettingsClientAPI = (*workloadmonitor.NotificationSettingsClient)(nil)