...

Source file src/github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus/rules.go

Documentation: github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus

     1  package servicebus
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // RulesClient is the azure Service Bus client
    19  type RulesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewRulesClient creates an instance of the RulesClient client.
    24  func NewRulesClient(subscriptionID string) RulesClient {
    25  	return NewRulesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewRulesClientWithBaseURI creates an instance of the RulesClient client using a custom endpoint.  Use this when
    29  // interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewRulesClientWithBaseURI(baseURI string, subscriptionID string) RulesClient {
    31  	return RulesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate creates a new rule and updates an existing rule
    35  // Parameters:
    36  // resourceGroupName - name of the Resource group within the Azure subscription.
    37  // namespaceName - the namespace name
    38  // topicName - the topic name.
    39  // subscriptionName - the subscription name.
    40  // ruleName - the rule name.
    41  // parameters - parameters supplied to create a rule.
    42  func (client RulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string, parameters Rule) (result Rule, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.Response.Response != nil {
    48  				sc = result.Response.Response.StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: resourceGroupName,
    55  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    57  		{TargetValue: namespaceName,
    58  			Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    59  				{Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}},
    60  		{TargetValue: topicName,
    61  			Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    62  		{TargetValue: subscriptionName,
    63  			Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    64  				{Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    65  		{TargetValue: ruleName,
    66  			Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    67  				{Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    68  		{TargetValue: parameters,
    69  			Constraints: []validation.Constraint{{Target: "parameters.Ruleproperties", Name: validation.Null, Rule: false,
    70  				Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter", Name: validation.Null, Rule: false,
    71  					Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.Null, Rule: false,
    72  						Chain: []validation.Constraint{{Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil},
    73  							{Target: "parameters.Ruleproperties.SQLFilter.CompatibilityLevel", Name: validation.InclusiveMinimum, Rule: int64(20), Chain: nil},
    74  						}},
    75  					}},
    76  				}}}}}); err != nil {
    77  		return result, validation.NewError("servicebus.RulesClient", "CreateOrUpdate", err.Error())
    78  	}
    79  
    80  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName, parameters)
    81  	if err != nil {
    82  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", nil, "Failure preparing request")
    83  		return
    84  	}
    85  
    86  	resp, err := client.CreateOrUpdateSender(req)
    87  	if err != nil {
    88  		result.Response = autorest.Response{Response: resp}
    89  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", resp, "Failure sending request")
    90  		return
    91  	}
    92  
    93  	result, err = client.CreateOrUpdateResponder(resp)
    94  	if err != nil {
    95  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", resp, "Failure responding to request")
    96  		return
    97  	}
    98  
    99  	return
   100  }
   101  
   102  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   103  func (client RulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string, parameters Rule) (*http.Request, error) {
   104  	pathParameters := map[string]interface{}{
   105  		"namespaceName":     autorest.Encode("path", namespaceName),
   106  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   107  		"ruleName":          autorest.Encode("path", ruleName),
   108  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   109  		"subscriptionName":  autorest.Encode("path", subscriptionName),
   110  		"topicName":         autorest.Encode("path", topicName),
   111  	}
   112  
   113  	const APIVersion = "2017-04-01"
   114  	queryParameters := map[string]interface{}{
   115  		"api-version": APIVersion,
   116  	}
   117  
   118  	preparer := autorest.CreatePreparer(
   119  		autorest.AsContentType("application/json; charset=utf-8"),
   120  		autorest.AsPut(),
   121  		autorest.WithBaseURL(client.BaseURI),
   122  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters),
   123  		autorest.WithJSON(parameters),
   124  		autorest.WithQueryParameters(queryParameters))
   125  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   126  }
   127  
   128  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   129  // http.Response Body if it receives an error.
   130  func (client RulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   131  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   132  }
   133  
   134  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   135  // closes the http.Response Body.
   136  func (client RulesClient) CreateOrUpdateResponder(resp *http.Response) (result Rule, err error) {
   137  	err = autorest.Respond(
   138  		resp,
   139  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   140  		autorest.ByUnmarshallingJSON(&result),
   141  		autorest.ByClosing())
   142  	result.Response = autorest.Response{Response: resp}
   143  	return
   144  }
   145  
   146  // Delete deletes an existing rule.
   147  // Parameters:
   148  // resourceGroupName - name of the Resource group within the Azure subscription.
   149  // namespaceName - the namespace name
   150  // topicName - the topic name.
   151  // subscriptionName - the subscription name.
   152  // ruleName - the rule name.
   153  func (client RulesClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (result autorest.Response, err error) {
   154  	if tracing.IsEnabled() {
   155  		ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.Delete")
   156  		defer func() {
   157  			sc := -1
   158  			if result.Response != nil {
   159  				sc = result.Response.StatusCode
   160  			}
   161  			tracing.EndSpan(ctx, sc, err)
   162  		}()
   163  	}
   164  	if err := validation.Validate([]validation.Validation{
   165  		{TargetValue: resourceGroupName,
   166  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   167  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   168  		{TargetValue: namespaceName,
   169  			Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   170  				{Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}},
   171  		{TargetValue: topicName,
   172  			Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   173  		{TargetValue: subscriptionName,
   174  			Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   175  				{Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   176  		{TargetValue: ruleName,
   177  			Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   178  				{Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   179  		return result, validation.NewError("servicebus.RulesClient", "Delete", err.Error())
   180  	}
   181  
   182  	req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName)
   183  	if err != nil {
   184  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", nil, "Failure preparing request")
   185  		return
   186  	}
   187  
   188  	resp, err := client.DeleteSender(req)
   189  	if err != nil {
   190  		result.Response = resp
   191  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", resp, "Failure sending request")
   192  		return
   193  	}
   194  
   195  	result, err = client.DeleteResponder(resp)
   196  	if err != nil {
   197  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", resp, "Failure responding to request")
   198  		return
   199  	}
   200  
   201  	return
   202  }
   203  
   204  // DeletePreparer prepares the Delete request.
   205  func (client RulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (*http.Request, error) {
   206  	pathParameters := map[string]interface{}{
   207  		"namespaceName":     autorest.Encode("path", namespaceName),
   208  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   209  		"ruleName":          autorest.Encode("path", ruleName),
   210  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   211  		"subscriptionName":  autorest.Encode("path", subscriptionName),
   212  		"topicName":         autorest.Encode("path", topicName),
   213  	}
   214  
   215  	const APIVersion = "2017-04-01"
   216  	queryParameters := map[string]interface{}{
   217  		"api-version": APIVersion,
   218  	}
   219  
   220  	preparer := autorest.CreatePreparer(
   221  		autorest.AsDelete(),
   222  		autorest.WithBaseURL(client.BaseURI),
   223  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters),
   224  		autorest.WithQueryParameters(queryParameters))
   225  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   226  }
   227  
   228  // DeleteSender sends the Delete request. The method will close the
   229  // http.Response Body if it receives an error.
   230  func (client RulesClient) DeleteSender(req *http.Request) (*http.Response, error) {
   231  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   232  }
   233  
   234  // DeleteResponder handles the response to the Delete request. The method always
   235  // closes the http.Response Body.
   236  func (client RulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   237  	err = autorest.Respond(
   238  		resp,
   239  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   240  		autorest.ByClosing())
   241  	result.Response = resp
   242  	return
   243  }
   244  
   245  // Get retrieves the description for the specified rule.
   246  // Parameters:
   247  // resourceGroupName - name of the Resource group within the Azure subscription.
   248  // namespaceName - the namespace name
   249  // topicName - the topic name.
   250  // subscriptionName - the subscription name.
   251  // ruleName - the rule name.
   252  func (client RulesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (result Rule, err error) {
   253  	if tracing.IsEnabled() {
   254  		ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.Get")
   255  		defer func() {
   256  			sc := -1
   257  			if result.Response.Response != nil {
   258  				sc = result.Response.Response.StatusCode
   259  			}
   260  			tracing.EndSpan(ctx, sc, err)
   261  		}()
   262  	}
   263  	if err := validation.Validate([]validation.Validation{
   264  		{TargetValue: resourceGroupName,
   265  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   266  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   267  		{TargetValue: namespaceName,
   268  			Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   269  				{Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}},
   270  		{TargetValue: topicName,
   271  			Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   272  		{TargetValue: subscriptionName,
   273  			Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   274  				{Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   275  		{TargetValue: ruleName,
   276  			Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   277  				{Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   278  		return result, validation.NewError("servicebus.RulesClient", "Get", err.Error())
   279  	}
   280  
   281  	req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName)
   282  	if err != nil {
   283  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", nil, "Failure preparing request")
   284  		return
   285  	}
   286  
   287  	resp, err := client.GetSender(req)
   288  	if err != nil {
   289  		result.Response = autorest.Response{Response: resp}
   290  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", resp, "Failure sending request")
   291  		return
   292  	}
   293  
   294  	result, err = client.GetResponder(resp)
   295  	if err != nil {
   296  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", resp, "Failure responding to request")
   297  		return
   298  	}
   299  
   300  	return
   301  }
   302  
   303  // GetPreparer prepares the Get request.
   304  func (client RulesClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (*http.Request, error) {
   305  	pathParameters := map[string]interface{}{
   306  		"namespaceName":     autorest.Encode("path", namespaceName),
   307  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   308  		"ruleName":          autorest.Encode("path", ruleName),
   309  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   310  		"subscriptionName":  autorest.Encode("path", subscriptionName),
   311  		"topicName":         autorest.Encode("path", topicName),
   312  	}
   313  
   314  	const APIVersion = "2017-04-01"
   315  	queryParameters := map[string]interface{}{
   316  		"api-version": APIVersion,
   317  	}
   318  
   319  	preparer := autorest.CreatePreparer(
   320  		autorest.AsGet(),
   321  		autorest.WithBaseURL(client.BaseURI),
   322  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters),
   323  		autorest.WithQueryParameters(queryParameters))
   324  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   325  }
   326  
   327  // GetSender sends the Get request. The method will close the
   328  // http.Response Body if it receives an error.
   329  func (client RulesClient) GetSender(req *http.Request) (*http.Response, error) {
   330  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   331  }
   332  
   333  // GetResponder handles the response to the Get request. The method always
   334  // closes the http.Response Body.
   335  func (client RulesClient) GetResponder(resp *http.Response) (result Rule, err error) {
   336  	err = autorest.Respond(
   337  		resp,
   338  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   339  		autorest.ByUnmarshallingJSON(&result),
   340  		autorest.ByClosing())
   341  	result.Response = autorest.Response{Response: resp}
   342  	return
   343  }
   344  
   345  // ListBySubscriptions list all the rules within given topic-subscription
   346  // Parameters:
   347  // resourceGroupName - name of the Resource group within the Azure subscription.
   348  // namespaceName - the namespace name
   349  // topicName - the topic name.
   350  // subscriptionName - the subscription name.
   351  // skip - skip is only used if a previous operation returned a partial result. If a previous response contains
   352  // a nextLink element, the value of the nextLink element will include a skip parameter that specifies a
   353  // starting point to use for subsequent calls.
   354  // top - may be used to limit the number of results to the most recent N usageDetails.
   355  func (client RulesClient) ListBySubscriptions(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (result RuleListResultPage, err error) {
   356  	if tracing.IsEnabled() {
   357  		ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.ListBySubscriptions")
   358  		defer func() {
   359  			sc := -1
   360  			if result.rlr.Response.Response != nil {
   361  				sc = result.rlr.Response.Response.StatusCode
   362  			}
   363  			tracing.EndSpan(ctx, sc, err)
   364  		}()
   365  	}
   366  	if err := validation.Validate([]validation.Validation{
   367  		{TargetValue: resourceGroupName,
   368  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   369  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   370  		{TargetValue: namespaceName,
   371  			Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   372  				{Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}},
   373  		{TargetValue: topicName,
   374  			Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   375  		{TargetValue: subscriptionName,
   376  			Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   377  				{Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   378  		{TargetValue: skip,
   379  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   380  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   381  					{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
   382  				}}}},
   383  		{TargetValue: top,
   384  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   385  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   386  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   387  				}}}}}); err != nil {
   388  		return result, validation.NewError("servicebus.RulesClient", "ListBySubscriptions", err.Error())
   389  	}
   390  
   391  	result.fn = client.listBySubscriptionsNextResults
   392  	req, err := client.ListBySubscriptionsPreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, skip, top)
   393  	if err != nil {
   394  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", nil, "Failure preparing request")
   395  		return
   396  	}
   397  
   398  	resp, err := client.ListBySubscriptionsSender(req)
   399  	if err != nil {
   400  		result.rlr.Response = autorest.Response{Response: resp}
   401  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", resp, "Failure sending request")
   402  		return
   403  	}
   404  
   405  	result.rlr, err = client.ListBySubscriptionsResponder(resp)
   406  	if err != nil {
   407  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", resp, "Failure responding to request")
   408  		return
   409  	}
   410  	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
   411  		err = result.NextWithContext(ctx)
   412  		return
   413  	}
   414  
   415  	return
   416  }
   417  
   418  // ListBySubscriptionsPreparer prepares the ListBySubscriptions request.
   419  func (client RulesClient) ListBySubscriptionsPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (*http.Request, error) {
   420  	pathParameters := map[string]interface{}{
   421  		"namespaceName":     autorest.Encode("path", namespaceName),
   422  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   423  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   424  		"subscriptionName":  autorest.Encode("path", subscriptionName),
   425  		"topicName":         autorest.Encode("path", topicName),
   426  	}
   427  
   428  	const APIVersion = "2017-04-01"
   429  	queryParameters := map[string]interface{}{
   430  		"api-version": APIVersion,
   431  	}
   432  	if skip != nil {
   433  		queryParameters["$skip"] = autorest.Encode("query", *skip)
   434  	}
   435  	if top != nil {
   436  		queryParameters["$top"] = autorest.Encode("query", *top)
   437  	}
   438  
   439  	preparer := autorest.CreatePreparer(
   440  		autorest.AsGet(),
   441  		autorest.WithBaseURL(client.BaseURI),
   442  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", pathParameters),
   443  		autorest.WithQueryParameters(queryParameters))
   444  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   445  }
   446  
   447  // ListBySubscriptionsSender sends the ListBySubscriptions request. The method will close the
   448  // http.Response Body if it receives an error.
   449  func (client RulesClient) ListBySubscriptionsSender(req *http.Request) (*http.Response, error) {
   450  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   451  }
   452  
   453  // ListBySubscriptionsResponder handles the response to the ListBySubscriptions request. The method always
   454  // closes the http.Response Body.
   455  func (client RulesClient) ListBySubscriptionsResponder(resp *http.Response) (result RuleListResult, err error) {
   456  	err = autorest.Respond(
   457  		resp,
   458  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   459  		autorest.ByUnmarshallingJSON(&result),
   460  		autorest.ByClosing())
   461  	result.Response = autorest.Response{Response: resp}
   462  	return
   463  }
   464  
   465  // listBySubscriptionsNextResults retrieves the next set of results, if any.
   466  func (client RulesClient) listBySubscriptionsNextResults(ctx context.Context, lastResults RuleListResult) (result RuleListResult, err error) {
   467  	req, err := lastResults.ruleListResultPreparer(ctx)
   468  	if err != nil {
   469  		return result, autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", nil, "Failure preparing next results request")
   470  	}
   471  	if req == nil {
   472  		return
   473  	}
   474  	resp, err := client.ListBySubscriptionsSender(req)
   475  	if err != nil {
   476  		result.Response = autorest.Response{Response: resp}
   477  		return result, autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", resp, "Failure sending next results request")
   478  	}
   479  	result, err = client.ListBySubscriptionsResponder(resp)
   480  	if err != nil {
   481  		err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", resp, "Failure responding to next results request")
   482  	}
   483  	return
   484  }
   485  
   486  // ListBySubscriptionsComplete enumerates all values, automatically crossing page boundaries as required.
   487  func (client RulesClient) ListBySubscriptionsComplete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (result RuleListResultIterator, err error) {
   488  	if tracing.IsEnabled() {
   489  		ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.ListBySubscriptions")
   490  		defer func() {
   491  			sc := -1
   492  			if result.Response().Response.Response != nil {
   493  				sc = result.page.Response().Response.Response.StatusCode
   494  			}
   495  			tracing.EndSpan(ctx, sc, err)
   496  		}()
   497  	}
   498  	result.page, err = client.ListBySubscriptions(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, skip, top)
   499  	return
   500  }
   501  

View as plain text