From ad3cba7253c47e38d3f364bd770ea2cb5c91cfe6 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 19 Nov 2018 05:35:03 +0000 Subject: [PATCH 1/5] Generated from 703983c70efacc80c3ada77f0cdcdfbb9f71a754 Merge branch 'master' into master --- .../mgmt/workloadmonitor/models.go | 8 - .../workloadmonitor/models.go | 216 ++++++------------ .../workloadmonitor/notificationsettings.go | 120 +++++++--- .../workloadmonitorapi/interfaces.go | 3 +- 4 files changed, 156 insertions(+), 191 deletions(-) diff --git a/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go b/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go index b140e9c6542e..83359c666555 100644 --- a/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go +++ b/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go @@ -124,8 +124,6 @@ type MonitorsCollectionPage = original.MonitorsCollectionPage type NotificationSetting = original.NotificationSetting type NotificationSettingProperties = original.NotificationSettingProperties type NotificationSettingsCollection = original.NotificationSettingsCollection -type NotificationSettingsCollectionIterator = original.NotificationSettingsCollectionIterator -type NotificationSettingsCollectionPage = original.NotificationSettingsCollectionPage type Operation = original.Operation type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator @@ -200,12 +198,6 @@ func NewMonitorsCollectionIterator(page MonitorsCollectionPage) MonitorsCollecti func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollection) (MonitorsCollection, error)) MonitorsCollectionPage { return original.NewMonitorsCollectionPage(getNextPage) } -func NewNotificationSettingsCollectionIterator(page NotificationSettingsCollectionPage) NotificationSettingsCollectionIterator { - return original.NewNotificationSettingsCollectionIterator(page) -} -func NewNotificationSettingsCollectionPage(getNextPage func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error)) NotificationSettingsCollectionPage { - return original.NewNotificationSettingsCollectionPage(getNextPage) -} func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { return original.NewOperationListResultIterator(page) } 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..64c04d7219a0 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,9 @@ func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollect return MonitorsCollectionPage{fn: getNextPage} } -// NotificationSetting model for component. +// NotificationSetting model for NotificationSetting. type NotificationSetting struct { - // 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"` @@ -1216,9 +1214,6 @@ type NotificationSetting struct { // MarshalJSON is the custom marshaler for NotificationSetting. func (ns NotificationSetting) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ns.Etag != nil { - objectMap["etag"] = ns.Etag - } if ns.NotificationSettingProperties != nil { objectMap["properties"] = ns.NotificationSettingProperties } @@ -1243,15 +1238,6 @@ func (ns *NotificationSetting) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "etag": - if v != nil { - var etag string - err = json.Unmarshal(*v, &etag) - if err != nil { - return err - } - ns.Etag = &etag - } case "properties": if v != nil { var notificationSettingProperties NotificationSettingProperties @@ -1296,155 +1282,89 @@ 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:"-"` - // 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 -// values. -type NotificationSettingsCollectionIterator struct { - i int - page NotificationSettingsCollectionPage + autorest.Response `json:"-"` + *NotificationSetting `json:"properties,omitempty"` + // Name - Resource name of NotificationSettings + Name *string `json:"name,omitempty"` + // ID - ARM resource ID of notification settings + ID *string `json:"id,omitempty"` + // Type - Resource type of NotificationSettings + Type *string `json:"type,omitempty"` } -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *NotificationSettingsCollectionIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() +// MarshalJSON is the custom marshaler for NotificationSettingsCollection. +func (nsc NotificationSettingsCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nsc.NotificationSetting != nil { + objectMap["properties"] = nsc.NotificationSetting } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil + if nsc.Name != nil { + objectMap["name"] = nsc.Name } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err + if nsc.ID != nil { + objectMap["id"] = nsc.ID } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *NotificationSettingsCollectionIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter NotificationSettingsCollectionIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter NotificationSettingsCollectionIterator) Response() NotificationSettingsCollection { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter NotificationSettingsCollectionIterator) Value() NotificationSetting { - if !iter.page.NotDone() { - return NotificationSetting{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the NotificationSettingsCollectionIterator type. -func NewNotificationSettingsCollectionIterator(page NotificationSettingsCollectionPage) NotificationSettingsCollectionIterator { - return NotificationSettingsCollectionIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (nsc NotificationSettingsCollection) IsEmpty() bool { - return nsc.Value == nil || len(*nsc.Value) == 0 -} - -// notificationSettingsCollectionPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (nsc NotificationSettingsCollection) notificationSettingsCollectionPreparer(ctx context.Context) (*http.Request, error) { - if nsc.NextLink == nil || len(to.String(nsc.NextLink)) < 1 { - return nil, nil + if nsc.Type != nil { + objectMap["type"] = nsc.Type } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(nsc.NextLink))) -} - -// NotificationSettingsCollectionPage contains a page of NotificationSetting values. -type NotificationSettingsCollectionPage struct { - fn func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error) - nsc NotificationSettingsCollection + return json.Marshal(objectMap) } -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *NotificationSettingsCollectionPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.nsc) +// UnmarshalJSON is the custom unmarshaler for NotificationSettingsCollection struct. +func (nsc *NotificationSettingsCollection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { return err } - page.nsc = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *NotificationSettingsCollectionPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page NotificationSettingsCollectionPage) NotDone() bool { - return !page.nsc.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page NotificationSettingsCollectionPage) Response() NotificationSettingsCollection { - return page.nsc -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page NotificationSettingsCollectionPage) Values() []NotificationSetting { - if page.nsc.IsEmpty() { - return nil + for k, v := range m { + switch k { + case "properties": + if v != nil { + var notificationSetting NotificationSetting + err = json.Unmarshal(*v, ¬ificationSetting) + if err != nil { + return err + } + nsc.NotificationSetting = ¬ificationSetting + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nsc.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nsc.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nsc.Type = &typeVar + } + } } - return *page.nsc.Value -} -// Creates a new instance of the NotificationSettingsCollectionPage type. -func NewNotificationSettingsCollectionPage(getNextPage func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error)) NotificationSettingsCollectionPage { - return NotificationSettingsCollectionPage{fn: getNextPage} + return nil } // Operation operation supported by the resource provider. 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..8bd5673c9734 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 @@ -47,14 +47,13 @@ func NewNotificationSettingsClientWithBaseURI(baseURI string, subscriptionID str // resourceNamespace - the Namespace of the resource. // resourceType - the type of the resource. // resourceName - name of the resource. -// skiptoken - the page-continuation token to use with a paged version of this API. -func (client NotificationSettingsClient) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result NotificationSettingsCollectionPage, err error) { +func (client NotificationSettingsClient) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result NotificationSettingsCollection, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.ListByResource") defer func() { sc := -1 - if result.nsc.Response.Response != nil { - sc = result.nsc.Response.Response.StatusCode + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -69,8 +68,7 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "ListByResource", err.Error()) } - result.fn = client.listByResourceNextResults - req, err := client.ListByResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, skiptoken) + req, err := client.ListByResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", nil, "Failure preparing request") return @@ -78,12 +76,12 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res resp, err := client.ListByResourceSender(req) if err != nil { - result.nsc.Response = autorest.Response{Response: resp} + result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", resp, "Failure sending request") return } - result.nsc, err = client.ListByResourceResponder(resp) + result, err = client.ListByResourceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", resp, "Failure responding to request") } @@ -92,7 +90,7 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res } // ListByResourcePreparer prepares the ListByResource request. -func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (*http.Request, error) { +func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), @@ -105,9 +103,6 @@ func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Cont queryParameters := map[string]interface{}{ "api-version": APIVersion, } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -137,39 +132,96 @@ func (client NotificationSettingsClient) ListByResourceResponder(resp *http.Resp return } -// listByResourceNextResults retrieves the next set of results, if any. -func (client NotificationSettingsClient) listByResourceNextResults(ctx context.Context, lastResults NotificationSettingsCollection) (result NotificationSettingsCollection, err error) { - req, err := lastResults.notificationSettingsCollectionPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", nil, "Failure preparing next results request") +// 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 NotificationSettingsCollection, 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 req == nil { + 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.ListByResourceSender(req) + + resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", resp, "Failure sending next results request") + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", resp, "Failure sending request") + return } - result, err = client.ListByResourceResponder(resp) + + result, err = client.UpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", resp, "Failure responding to request") } + return } -// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required. -func (client NotificationSettingsClient) ListByResourceComplete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result NotificationSettingsCollectionIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.ListByResource") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() +// 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{}{ + "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), } - result.page, err = client.ListByResource(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, skiptoken) + + 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", 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 NotificationSettingsCollection, 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..50ab8e541338 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,8 @@ var _ MonitorInstancesClientAPI = (*workloadmonitor.MonitorInstancesClient)(nil) // NotificationSettingsClientAPI contains the set of methods on the NotificationSettingsClient type. type NotificationSettingsClientAPI interface { - ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result workloadmonitor.NotificationSettingsCollectionPage, err error) + ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result workloadmonitor.NotificationSettingsCollection, err error) + Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSettingsCollection, err error) } var _ NotificationSettingsClientAPI = (*workloadmonitor.NotificationSettingsClient)(nil) From b51f674c4561c3aa79813f3494de45a9af5c4f5a Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 21 Nov 2018 08:50:42 +0000 Subject: [PATCH 2/5] Generated from 998f97029f6ce81df093e60c816fb76ed25421b7 Adding examples --- .../workloadmonitor/notificationsettings.go | 113 ++++++++++++++++-- .../workloadmonitorapi/interfaces.go | 3 +- 2 files changed, 106 insertions(+), 10 deletions(-) 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 8bd5673c9734..5f2ba8889809 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,99 @@ 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. +// notificationSettingName - name of the notificationSetting +func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string) (result NotificationSettingsCollection, 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, notificationSettingName) + 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, notificationSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationSettingName": autorest.Encode("path", notificationSettingName), + "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 NotificationSettingsCollection, 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. @@ -138,8 +231,9 @@ func (client NotificationSettingsClient) ListByResourceResponder(resp *http.Resp // resourceNamespace - the Namespace of the resource. // resourceType - the type of the resource. // resourceName - name of the resource. +// notificationSettingName - name of the notificationSetting // 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 NotificationSettingsCollection, err error) { +func (client NotificationSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (result NotificationSettingsCollection, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.Update") defer func() { @@ -160,7 +254,7 @@ func (client NotificationSettingsClient) Update(ctx context.Context, resourceGro return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "Update", err.Error()) } - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, body) + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, notificationSettingName, body) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Update", nil, "Failure preparing request") return @@ -182,13 +276,14 @@ func (client NotificationSettingsClient) Update(ctx context.Context, resourceGro } // 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) { +func (client NotificationSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (*http.Request, error) { pathParameters := map[string]interface{}{ - "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), + "notificationSettingName": autorest.Encode("path", notificationSettingName), + "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" @@ -200,7 +295,7 @@ func (client NotificationSettingsClient) UpdatePreparer(ctx context.Context, res 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", pathParameters), + 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)) 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 50ab8e541338..3974a8f65983 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,8 +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, notificationSettingName string) (result workloadmonitor.NotificationSettingsCollection, err error) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result workloadmonitor.NotificationSettingsCollection, err error) - Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSettingsCollection, err error) + Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSettingsCollection, err error) } var _ NotificationSettingsClientAPI = (*workloadmonitor.NotificationSettingsClient)(nil) From fba3da83d9a5e6a2f6bdbf3212ec795a5440ba7a Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 26 Nov 2018 18:39:20 +0000 Subject: [PATCH 3/5] Generated from a5f92e4f9f8dda539ea3fba93cf842c676fcad72 Merge branch 'master' of https://github.com/vivek-microsoft/azure-rest-api-specs --- .../workloadmonitor/models.go | 93 ++++--------------- 1 file changed, 16 insertions(+), 77 deletions(-) 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 64c04d7219a0..a1154006dadc 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 @@ -1201,6 +1201,8 @@ func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollect // NotificationSetting model for NotificationSetting. type NotificationSetting struct { + // Etag - For optimistic concurrency control. + Etag *string `json:"etag,omitempty"` // 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} @@ -1214,6 +1216,9 @@ type NotificationSetting struct { // MarshalJSON is the custom marshaler for NotificationSetting. func (ns NotificationSetting) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if ns.Etag != nil { + objectMap["etag"] = ns.Etag + } if ns.NotificationSettingProperties != nil { objectMap["properties"] = ns.NotificationSettingProperties } @@ -1238,6 +1243,15 @@ func (ns *NotificationSetting) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + ns.Etag = &etag + } case "properties": if v != nil { var notificationSettingProperties NotificationSettingProperties @@ -1288,83 +1302,8 @@ type NotificationSettingProperties struct { // NotificationSettingsCollection model for collection of notificationSettings. type NotificationSettingsCollection struct { - autorest.Response `json:"-"` - *NotificationSetting `json:"properties,omitempty"` - // Name - Resource name of NotificationSettings - Name *string `json:"name,omitempty"` - // ID - ARM resource ID of notification settings - ID *string `json:"id,omitempty"` - // Type - Resource type of NotificationSettings - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for NotificationSettingsCollection. -func (nsc NotificationSettingsCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if nsc.NotificationSetting != nil { - objectMap["properties"] = nsc.NotificationSetting - } - if nsc.Name != nil { - objectMap["name"] = nsc.Name - } - if nsc.ID != nil { - objectMap["id"] = nsc.ID - } - if nsc.Type != nil { - objectMap["type"] = nsc.Type - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for NotificationSettingsCollection struct. -func (nsc *NotificationSettingsCollection) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var notificationSetting NotificationSetting - err = json.Unmarshal(*v, ¬ificationSetting) - if err != nil { - return err - } - nsc.NotificationSetting = ¬ificationSetting - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - nsc.Name = &name - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - nsc.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - nsc.Type = &typeVar - } - } - } - - return nil + autorest.Response `json:"-"` + Value *[]NotificationSetting `json:"value,omitempty"` } // Operation operation supported by the resource provider. From b8900a62becf4676139104bb0e0718eb6d61e5cc Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 27 Nov 2018 16:56:14 +0000 Subject: [PATCH 4/5] Generated from a49a4bbb7857320cebd348da5b9814a81a844b1d Fixing json format --- .../mgmt/workloadmonitor/models.go | 8 + .../workloadmonitor/models.go | 141 ++++++++++++++++++ .../workloadmonitor/notificationsettings.go | 64 ++++++-- .../workloadmonitorapi/interfaces.go | 6 +- 4 files changed, 205 insertions(+), 14 deletions(-) diff --git a/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go b/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go index 83359c666555..b140e9c6542e 100644 --- a/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go +++ b/profiles/preview/preview/workloadmonitor/mgmt/workloadmonitor/models.go @@ -124,6 +124,8 @@ type MonitorsCollectionPage = original.MonitorsCollectionPage type NotificationSetting = original.NotificationSetting type NotificationSettingProperties = original.NotificationSettingProperties type NotificationSettingsCollection = original.NotificationSettingsCollection +type NotificationSettingsCollectionIterator = original.NotificationSettingsCollectionIterator +type NotificationSettingsCollectionPage = original.NotificationSettingsCollectionPage type Operation = original.Operation type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator @@ -198,6 +200,12 @@ func NewMonitorsCollectionIterator(page MonitorsCollectionPage) MonitorsCollecti func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollection) (MonitorsCollection, error)) MonitorsCollectionPage { return original.NewMonitorsCollectionPage(getNextPage) } +func NewNotificationSettingsCollectionIterator(page NotificationSettingsCollectionPage) NotificationSettingsCollectionIterator { + return original.NewNotificationSettingsCollectionIterator(page) +} +func NewNotificationSettingsCollectionPage(getNextPage func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error)) NotificationSettingsCollectionPage { + return original.NewNotificationSettingsCollectionPage(getNextPage) +} func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { return original.NewOperationListResultIterator(page) } 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 a1154006dadc..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 @@ -1201,6 +1201,7 @@ func NewMonitorsCollectionPage(getNextPage func(context.Context, MonitorsCollect // NotificationSetting model for NotificationSetting. type NotificationSetting struct { + autorest.Response `json:"-"` // Etag - For optimistic concurrency control. Etag *string `json:"etag,omitempty"` // NotificationSettingProperties - Properties of Notification Settings @@ -1304,6 +1305,146 @@ type NotificationSettingProperties struct { type NotificationSettingsCollection struct { autorest.Response `json:"-"` Value *[]NotificationSetting `json:"value,omitempty"` + // NextLink - URL to the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// NotificationSettingsCollectionIterator provides access to a complete listing of NotificationSetting +// values. +type NotificationSettingsCollectionIterator struct { + i int + page NotificationSettingsCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *NotificationSettingsCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *NotificationSettingsCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter NotificationSettingsCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter NotificationSettingsCollectionIterator) Response() NotificationSettingsCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter NotificationSettingsCollectionIterator) Value() NotificationSetting { + if !iter.page.NotDone() { + return NotificationSetting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the NotificationSettingsCollectionIterator type. +func NewNotificationSettingsCollectionIterator(page NotificationSettingsCollectionPage) NotificationSettingsCollectionIterator { + return NotificationSettingsCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (nsc NotificationSettingsCollection) IsEmpty() bool { + return nsc.Value == nil || len(*nsc.Value) == 0 +} + +// notificationSettingsCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (nsc NotificationSettingsCollection) notificationSettingsCollectionPreparer(ctx context.Context) (*http.Request, error) { + if nsc.NextLink == nil || len(to.String(nsc.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(nsc.NextLink))) +} + +// NotificationSettingsCollectionPage contains a page of NotificationSetting values. +type NotificationSettingsCollectionPage struct { + fn func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error) + nsc NotificationSettingsCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *NotificationSettingsCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.nsc) + if err != nil { + return err + } + page.nsc = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *NotificationSettingsCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page NotificationSettingsCollectionPage) NotDone() bool { + return !page.nsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page NotificationSettingsCollectionPage) Response() NotificationSettingsCollection { + return page.nsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page NotificationSettingsCollectionPage) Values() []NotificationSetting { + if page.nsc.IsEmpty() { + return nil + } + return *page.nsc.Value +} + +// Creates a new instance of the NotificationSettingsCollectionPage type. +func NewNotificationSettingsCollectionPage(getNextPage func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error)) NotificationSettingsCollectionPage { + return NotificationSettingsCollectionPage{fn: getNextPage} } // Operation operation supported by the resource provider. 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 5f2ba8889809..acd31c69edf0 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 @@ -48,7 +48,7 @@ func NewNotificationSettingsClientWithBaseURI(baseURI string, subscriptionID str // resourceType - the type of the resource. // resourceName - name of the resource. // notificationSettingName - name of the notificationSetting -func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string) (result NotificationSettingsCollection, err error) { +func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string) (result NotificationSetting, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.Get") defer func() { @@ -123,7 +123,7 @@ func (client NotificationSettingsClient) GetSender(req *http.Request) (*http.Res // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client NotificationSettingsClient) GetResponder(resp *http.Response) (result NotificationSettingsCollection, err error) { +func (client NotificationSettingsClient) GetResponder(resp *http.Response) (result NotificationSetting, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -140,13 +140,14 @@ func (client NotificationSettingsClient) GetResponder(resp *http.Response) (resu // resourceNamespace - the Namespace of the resource. // resourceType - the type of the resource. // resourceName - name of the resource. -func (client NotificationSettingsClient) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result NotificationSettingsCollection, err error) { +// skiptoken - the page-continuation token to use with a paged version of this API. +func (client NotificationSettingsClient) ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result NotificationSettingsCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.ListByResource") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.nsc.Response.Response != nil { + sc = result.nsc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -161,7 +162,8 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "ListByResource", err.Error()) } - req, err := client.ListByResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + result.fn = client.listByResourceNextResults + req, err := client.ListByResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, skiptoken) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", nil, "Failure preparing request") return @@ -169,12 +171,12 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res resp, err := client.ListByResourceSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.nsc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", resp, "Failure sending request") return } - result, err = client.ListByResourceResponder(resp) + result.nsc, err = client.ListByResourceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "ListByResource", resp, "Failure responding to request") } @@ -183,7 +185,7 @@ func (client NotificationSettingsClient) ListByResource(ctx context.Context, res } // ListByResourcePreparer prepares the ListByResource request. -func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { +func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), @@ -196,6 +198,9 @@ func (client NotificationSettingsClient) ListByResourcePreparer(ctx context.Cont queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } preparer := autorest.CreatePreparer( autorest.AsGet(), @@ -225,6 +230,43 @@ func (client NotificationSettingsClient) ListByResourceResponder(resp *http.Resp return } +// listByResourceNextResults retrieves the next set of results, if any. +func (client NotificationSettingsClient) listByResourceNextResults(ctx context.Context, lastResults NotificationSettingsCollection) (result NotificationSettingsCollection, err error) { + req, err := lastResults.notificationSettingsCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "listByResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client NotificationSettingsClient) ListByResourceComplete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, skiptoken string) (result NotificationSettingsCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.ListByResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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. @@ -233,7 +275,7 @@ func (client NotificationSettingsClient) ListByResourceResponder(resp *http.Resp // resourceName - name of the resource. // notificationSettingName - name of the notificationSetting // body - body of the NotificationSetting PUT object. -func (client NotificationSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (result NotificationSettingsCollection, err error) { +func (client NotificationSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (result NotificationSetting, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsClient.Update") defer func() { @@ -310,7 +352,7 @@ func (client NotificationSettingsClient) UpdateSender(req *http.Request) (*http. // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client NotificationSettingsClient) UpdateResponder(resp *http.Response) (result NotificationSettingsCollection, err error) { +func (client NotificationSettingsClient) UpdateResponder(resp *http.Response) (result NotificationSetting, err error) { err = autorest.Respond( resp, client.ByInspecting(), 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 3974a8f65983..19fe6d504635 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,9 +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, notificationSettingName string) (result workloadmonitor.NotificationSettingsCollection, err error) - ListByResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result workloadmonitor.NotificationSettingsCollection, err error) - Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSettingsCollection, err error) + Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName 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, notificationSettingName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSetting, err error) } var _ NotificationSettingsClientAPI = (*workloadmonitor.NotificationSettingsClient)(nil) From 3383bf5d23b41de88268974ec0006583638f3906 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 27 Nov 2018 18:24:37 +0000 Subject: [PATCH 5/5] Generated from 305f074c9d23cc9b56d817ccfe930886423deb19 manual edit to refer to default parameter --- .../workloadmonitor/notificationsettings.go | 18 ++++++++---------- .../workloadmonitorapi/interfaces.go | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) 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 acd31c69edf0..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 @@ -47,8 +47,7 @@ func NewNotificationSettingsClientWithBaseURI(baseURI string, subscriptionID str // resourceNamespace - the Namespace of the resource. // resourceType - the type of the resource. // resourceName - name of the resource. -// notificationSettingName - name of the notificationSetting -func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string) (result NotificationSetting, err error) { +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() { @@ -69,7 +68,7 @@ func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupN return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "Get", err.Error()) } - req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, notificationSettingName) + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) if err != nil { err = autorest.NewErrorWithError(err, "workloadmonitor.NotificationSettingsClient", "Get", nil, "Failure preparing request") return @@ -91,9 +90,9 @@ func (client NotificationSettingsClient) Get(ctx context.Context, resourceGroupN } // GetPreparer prepares the Get request. -func (client NotificationSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string) (*http.Request, error) { +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", notificationSettingName), + "notificationSettingName": autorest.Encode("path", "default"), "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), "resourceNamespace": autorest.Encode("path", resourceNamespace), @@ -273,9 +272,8 @@ func (client NotificationSettingsClient) ListByResourceComplete(ctx context.Cont // resourceNamespace - the Namespace of the resource. // resourceType - the type of the resource. // resourceName - name of the resource. -// notificationSettingName - name of the notificationSetting // body - body of the NotificationSetting PUT object. -func (client NotificationSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (result NotificationSetting, err error) { +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() { @@ -296,7 +294,7 @@ func (client NotificationSettingsClient) Update(ctx context.Context, resourceGro return result, validation.NewError("workloadmonitor.NotificationSettingsClient", "Update", err.Error()) } - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, notificationSettingName, body) + 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 @@ -318,9 +316,9 @@ func (client NotificationSettingsClient) Update(ctx context.Context, resourceGro } // UpdatePreparer prepares the Update request. -func (client NotificationSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, notificationSettingName string, body NotificationSetting) (*http.Request, error) { +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", notificationSettingName), + "notificationSettingName": autorest.Encode("path", "default"), "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), "resourceNamespace": autorest.Encode("path", resourceNamespace), 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 19fe6d504635..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,9 +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, notificationSettingName string) (result workloadmonitor.NotificationSetting, err error) + 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, notificationSettingName string, body workloadmonitor.NotificationSetting) (result workloadmonitor.NotificationSetting, 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)