diff --git a/profiles/latest/servicebus/mgmt/servicebus/models.go b/profiles/latest/servicebus/mgmt/servicebus/models.go index 74f148058c1e..fba494f170aa 100644 --- a/profiles/latest/servicebus/mgmt/servicebus/models.go +++ b/profiles/latest/servicebus/mgmt/servicebus/models.go @@ -175,6 +175,9 @@ type NamespacesClient = original.NamespacesClient type NamespacesCreateOrUpdateFuture = original.NamespacesCreateOrUpdateFuture type NamespacesDeleteFuture = original.NamespacesDeleteFuture type NetworkRuleSet = original.NetworkRuleSet +type NetworkRuleSetListResult = original.NetworkRuleSetListResult +type NetworkRuleSetListResultIterator = original.NetworkRuleSetListResultIterator +type NetworkRuleSetListResultPage = original.NetworkRuleSetListResultPage type NetworkRuleSetProperties = original.NetworkRuleSetProperties type Operation = original.Operation type OperationDisplay = original.OperationDisplay @@ -279,6 +282,12 @@ func NewNamespacesClient(subscriptionID string) NamespacesClient { func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) NamespacesClient { return original.NewNamespacesClientWithBaseURI(baseURI, subscriptionID) } +func NewNetworkRuleSetListResultIterator(page NetworkRuleSetListResultPage) NetworkRuleSetListResultIterator { + return original.NewNetworkRuleSetListResultIterator(page) +} +func NewNetworkRuleSetListResultPage(getNextPage func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error)) NetworkRuleSetListResultPage { + return original.NewNetworkRuleSetListResultPage(getNextPage) +} func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { return original.NewOperationListResultIterator(page) } diff --git a/profiles/preview/servicebus/mgmt/servicebus/models.go b/profiles/preview/servicebus/mgmt/servicebus/models.go index 1768e406ac4f..e92dd03050c6 100644 --- a/profiles/preview/servicebus/mgmt/servicebus/models.go +++ b/profiles/preview/servicebus/mgmt/servicebus/models.go @@ -175,6 +175,9 @@ type NamespacesClient = original.NamespacesClient type NamespacesCreateOrUpdateFuture = original.NamespacesCreateOrUpdateFuture type NamespacesDeleteFuture = original.NamespacesDeleteFuture type NetworkRuleSet = original.NetworkRuleSet +type NetworkRuleSetListResult = original.NetworkRuleSetListResult +type NetworkRuleSetListResultIterator = original.NetworkRuleSetListResultIterator +type NetworkRuleSetListResultPage = original.NetworkRuleSetListResultPage type NetworkRuleSetProperties = original.NetworkRuleSetProperties type Operation = original.Operation type OperationDisplay = original.OperationDisplay @@ -279,6 +282,12 @@ func NewNamespacesClient(subscriptionID string) NamespacesClient { func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) NamespacesClient { return original.NewNamespacesClientWithBaseURI(baseURI, subscriptionID) } +func NewNetworkRuleSetListResultIterator(page NetworkRuleSetListResultPage) NetworkRuleSetListResultIterator { + return original.NewNetworkRuleSetListResultIterator(page) +} +func NewNetworkRuleSetListResultPage(getNextPage func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error)) NetworkRuleSetListResultPage { + return original.NewNetworkRuleSetListResultPage(getNextPage) +} func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { return original.NewOperationListResultIterator(page) } diff --git a/services/servicebus/mgmt/2017-04-01/servicebus/models.go b/services/servicebus/mgmt/2017-04-01/servicebus/models.go index bf6b8001396c..f737cf2ea88a 100644 --- a/services/servicebus/mgmt/2017-04-01/servicebus/models.go +++ b/services/servicebus/mgmt/2017-04-01/servicebus/models.go @@ -1335,6 +1335,152 @@ func (nrs *NetworkRuleSet) UnmarshalJSON(body []byte) error { return nil } +// NetworkRuleSetListResult the response of the List NetworkRuleSet operation. +type NetworkRuleSetListResult struct { + autorest.Response `json:"-"` + // Value - Result of the List NetworkRuleSet operation. + Value *[]NetworkRuleSet `json:"value,omitempty"` + // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. + NextLink *string `json:"nextLink,omitempty"` +} + +// NetworkRuleSetListResultIterator provides access to a complete listing of NetworkRuleSet values. +type NetworkRuleSetListResultIterator struct { + i int + page NetworkRuleSetListResultPage +} + +// 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 *NetworkRuleSetListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkRuleSetListResultIterator.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 *NetworkRuleSetListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter NetworkRuleSetListResultIterator) 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 NetworkRuleSetListResultIterator) Response() NetworkRuleSetListResult { + 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 NetworkRuleSetListResultIterator) Value() NetworkRuleSet { + if !iter.page.NotDone() { + return NetworkRuleSet{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the NetworkRuleSetListResultIterator type. +func NewNetworkRuleSetListResultIterator(page NetworkRuleSetListResultPage) NetworkRuleSetListResultIterator { + return NetworkRuleSetListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (nrslr NetworkRuleSetListResult) IsEmpty() bool { + return nrslr.Value == nil || len(*nrslr.Value) == 0 +} + +// networkRuleSetListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (nrslr NetworkRuleSetListResult) networkRuleSetListResultPreparer(ctx context.Context) (*http.Request, error) { + if nrslr.NextLink == nil || len(to.String(nrslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(nrslr.NextLink))) +} + +// NetworkRuleSetListResultPage contains a page of NetworkRuleSet values. +type NetworkRuleSetListResultPage struct { + fn func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error) + nrslr NetworkRuleSetListResult +} + +// 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 *NetworkRuleSetListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkRuleSetListResultPage.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.nrslr) + if err != nil { + return err + } + page.nrslr = 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 *NetworkRuleSetListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page NetworkRuleSetListResultPage) NotDone() bool { + return !page.nrslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page NetworkRuleSetListResultPage) Response() NetworkRuleSetListResult { + return page.nrslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page NetworkRuleSetListResultPage) Values() []NetworkRuleSet { + if page.nrslr.IsEmpty() { + return nil + } + return *page.nrslr.Value +} + +// Creates a new instance of the NetworkRuleSetListResultPage type. +func NewNetworkRuleSetListResultPage(getNextPage func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error)) NetworkRuleSetListResultPage { + return NetworkRuleSetListResultPage{fn: getNextPage} +} + // NetworkRuleSetProperties networkRuleSet properties type NetworkRuleSetProperties struct { // DefaultAction - Default Action for Network Rule Set. Possible values include: 'Allow', 'Deny' @@ -3400,7 +3546,7 @@ type SBTopicProperties struct { type SQLFilter struct { // SQLExpression - The SQL expression. e.g. MyProperty='ABC' SQLExpression *string `json:"sqlExpression,omitempty"` - // CompatibilityLevel - READ-ONLY; This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. + // CompatibilityLevel - This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. CompatibilityLevel *int32 `json:"compatibilityLevel,omitempty"` // RequiresPreprocessing - Value that indicates whether the rule action requires preprocessing. RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` diff --git a/services/servicebus/mgmt/2017-04-01/servicebus/namespaces.go b/services/servicebus/mgmt/2017-04-01/servicebus/namespaces.go index 8f63d12121e8..e9034b3b14cb 100644 --- a/services/servicebus/mgmt/2017-04-01/servicebus/namespaces.go +++ b/services/servicebus/mgmt/2017-04-01/servicebus/namespaces.go @@ -1289,6 +1289,131 @@ func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result Ac return } +// ListNetworkRuleSets gets list of NetworkRuleSet for a Namespace. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// namespaceName - the namespace name +func (client NamespacesClient) ListNetworkRuleSets(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSetListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListNetworkRuleSets") + defer func() { + sc := -1 + if result.nrslr.Response.Response != nil { + sc = result.nrslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("servicebus.NamespacesClient", "ListNetworkRuleSets", err.Error()) + } + + result.fn = client.listNetworkRuleSetsNextResults + req, err := client.ListNetworkRuleSetsPreparer(ctx, resourceGroupName, namespaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", nil, "Failure preparing request") + return + } + + resp, err := client.ListNetworkRuleSetsSender(req) + if err != nil { + result.nrslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", resp, "Failure sending request") + return + } + + result.nrslr, err = client.ListNetworkRuleSetsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", resp, "Failure responding to request") + } + + return +} + +// ListNetworkRuleSetsPreparer prepares the ListNetworkRuleSets request. +func (client NamespacesClient) ListNetworkRuleSetsPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListNetworkRuleSetsSender sends the ListNetworkRuleSets request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) ListNetworkRuleSetsSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListNetworkRuleSetsResponder handles the response to the ListNetworkRuleSets request. The method always +// closes the http.Response Body. +func (client NamespacesClient) ListNetworkRuleSetsResponder(resp *http.Response) (result NetworkRuleSetListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNetworkRuleSetsNextResults retrieves the next set of results, if any. +func (client NamespacesClient) listNetworkRuleSetsNextResults(ctx context.Context, lastResults NetworkRuleSetListResult) (result NetworkRuleSetListResult, err error) { + req, err := lastResults.networkRuleSetListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListNetworkRuleSetsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListNetworkRuleSetsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListNetworkRuleSetsComplete enumerates all values, automatically crossing page boundaries as required. +func (client NamespacesClient) ListNetworkRuleSetsComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSetListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListNetworkRuleSets") + 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.ListNetworkRuleSets(ctx, resourceGroupName, namespaceName) + return +} + // Migrate this operation Migrate the given namespace to provided name type // Parameters: // resourceGroupName - name of the Resource group within the Azure subscription. diff --git a/services/servicebus/mgmt/2017-04-01/servicebus/rules.go b/services/servicebus/mgmt/2017-04-01/servicebus/rules.go index 0d3357e5b6fc..4b12b65da8fe 100644 --- a/services/servicebus/mgmt/2017-04-01/servicebus/rules.go +++ b/services/servicebus/mgmt/2017-04-01/servicebus/rules.go @@ -74,7 +74,16 @@ func (client RulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: ruleName, Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + {Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Ruleproperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil}, + {Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.InclusiveMinimum, Rule: 20, Chain: nil}, + }}, + }}, + }}}}}); err != nil { return result, validation.NewError("servicebus.RulesClient", "CreateOrUpdate", err.Error()) } diff --git a/services/servicebus/mgmt/2017-04-01/servicebus/servicebusapi/interfaces.go b/services/servicebus/mgmt/2017-04-01/servicebus/servicebusapi/interfaces.go index 0c6bbd6f5999..a5a9dcb0efe7 100644 --- a/services/servicebus/mgmt/2017-04-01/servicebus/servicebusapi/interfaces.go +++ b/services/servicebus/mgmt/2017-04-01/servicebus/servicebusapi/interfaces.go @@ -45,6 +45,7 @@ type NamespacesClientAPI interface { ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string) (result servicebus.SBAuthorizationRuleListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result servicebus.SBNamespaceListResultPage, err error) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result servicebus.AccessKeys, err error) + ListNetworkRuleSets(ctx context.Context, resourceGroupName string, namespaceName string) (result servicebus.NetworkRuleSetListResultPage, err error) Migrate(ctx context.Context, resourceGroupName string, namespaceName string, parameters servicebus.SBNamespaceMigrate) (result autorest.Response, err error) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters servicebus.RegenerateAccessKeyParameters) (result servicebus.AccessKeys, err error) Update(ctx context.Context, resourceGroupName string, namespaceName string, parameters servicebus.SBNamespaceUpdateParameters) (result servicebus.SBNamespace, err error)