...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2021-10-15-preview/eventgrid/partnerconfigurations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2021-10-15-preview/eventgrid

     1  package eventgrid
     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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // PartnerConfigurationsClient is the azure EventGrid Management Client
    18  type PartnerConfigurationsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewPartnerConfigurationsClient creates an instance of the PartnerConfigurationsClient client.
    23  func NewPartnerConfigurationsClient(subscriptionID string) PartnerConfigurationsClient {
    24  	return NewPartnerConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewPartnerConfigurationsClientWithBaseURI creates an instance of the PartnerConfigurationsClient client using a
    28  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    29  // Azure stack).
    30  func NewPartnerConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) PartnerConfigurationsClient {
    31  	return PartnerConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // AuthorizePartner authorize a single partner either by partner registration immutable Id or by partner name.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group within the user's subscription.
    37  // partnerInfo - the information of the partner to be authorized.
    38  func (client PartnerConfigurationsClient) AuthorizePartner(ctx context.Context, resourceGroupName string, partnerInfo Partner) (result PartnerConfiguration, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.AuthorizePartner")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response.Response != nil {
    44  				sc = result.Response.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	req, err := client.AuthorizePartnerPreparer(ctx, resourceGroupName, partnerInfo)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "AuthorizePartner", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.AuthorizePartnerSender(req)
    56  	if err != nil {
    57  		result.Response = autorest.Response{Response: resp}
    58  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "AuthorizePartner", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result, err = client.AuthorizePartnerResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "AuthorizePartner", resp, "Failure responding to request")
    65  		return
    66  	}
    67  
    68  	return
    69  }
    70  
    71  // AuthorizePartnerPreparer prepares the AuthorizePartner request.
    72  func (client PartnerConfigurationsClient) AuthorizePartnerPreparer(ctx context.Context, resourceGroupName string, partnerInfo Partner) (*http.Request, error) {
    73  	pathParameters := map[string]interface{}{
    74  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    75  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    76  	}
    77  
    78  	const APIVersion = "2021-10-15-preview"
    79  	queryParameters := map[string]interface{}{
    80  		"api-version": APIVersion,
    81  	}
    82  
    83  	preparer := autorest.CreatePreparer(
    84  		autorest.AsContentType("application/json; charset=utf-8"),
    85  		autorest.AsPost(),
    86  		autorest.WithBaseURL(client.BaseURI),
    87  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner", pathParameters),
    88  		autorest.WithJSON(partnerInfo),
    89  		autorest.WithQueryParameters(queryParameters))
    90  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    91  }
    92  
    93  // AuthorizePartnerSender sends the AuthorizePartner request. The method will close the
    94  // http.Response Body if it receives an error.
    95  func (client PartnerConfigurationsClient) AuthorizePartnerSender(req *http.Request) (*http.Response, error) {
    96  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    97  }
    98  
    99  // AuthorizePartnerResponder handles the response to the AuthorizePartner request. The method always
   100  // closes the http.Response Body.
   101  func (client PartnerConfigurationsClient) AuthorizePartnerResponder(resp *http.Response) (result PartnerConfiguration, err error) {
   102  	err = autorest.Respond(
   103  		resp,
   104  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   105  		autorest.ByUnmarshallingJSON(&result),
   106  		autorest.ByClosing())
   107  	result.Response = autorest.Response{Response: resp}
   108  	return
   109  }
   110  
   111  // CreateOrUpdate synchronously creates or updates a partner configuration with the specified parameters.
   112  // Parameters:
   113  // resourceGroupName - the name of the resource group within the user's subscription.
   114  // partnerConfigurationInfo - partner configuration information.
   115  func (client PartnerConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, partnerConfigurationInfo PartnerConfiguration) (result PartnerConfigurationsCreateOrUpdateFuture, err error) {
   116  	if tracing.IsEnabled() {
   117  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.CreateOrUpdate")
   118  		defer func() {
   119  			sc := -1
   120  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   121  				sc = result.FutureAPI.Response().StatusCode
   122  			}
   123  			tracing.EndSpan(ctx, sc, err)
   124  		}()
   125  	}
   126  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, partnerConfigurationInfo)
   127  	if err != nil {
   128  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request")
   129  		return
   130  	}
   131  
   132  	result, err = client.CreateOrUpdateSender(req)
   133  	if err != nil {
   134  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
   135  		return
   136  	}
   137  
   138  	return
   139  }
   140  
   141  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   142  func (client PartnerConfigurationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, partnerConfigurationInfo PartnerConfiguration) (*http.Request, error) {
   143  	pathParameters := map[string]interface{}{
   144  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   145  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   146  	}
   147  
   148  	const APIVersion = "2021-10-15-preview"
   149  	queryParameters := map[string]interface{}{
   150  		"api-version": APIVersion,
   151  	}
   152  
   153  	partnerConfigurationInfo.SystemData = nil
   154  	preparer := autorest.CreatePreparer(
   155  		autorest.AsContentType("application/json; charset=utf-8"),
   156  		autorest.AsPut(),
   157  		autorest.WithBaseURL(client.BaseURI),
   158  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", pathParameters),
   159  		autorest.WithJSON(partnerConfigurationInfo),
   160  		autorest.WithQueryParameters(queryParameters))
   161  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   162  }
   163  
   164  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   165  // http.Response Body if it receives an error.
   166  func (client PartnerConfigurationsClient) CreateOrUpdateSender(req *http.Request) (future PartnerConfigurationsCreateOrUpdateFuture, err error) {
   167  	var resp *http.Response
   168  	future.FutureAPI = &azure.Future{}
   169  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   170  	if err != nil {
   171  		return
   172  	}
   173  	var azf azure.Future
   174  	azf, err = azure.NewFutureFromResponse(resp)
   175  	future.FutureAPI = &azf
   176  	future.Result = future.result
   177  	return
   178  }
   179  
   180  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   181  // closes the http.Response Body.
   182  func (client PartnerConfigurationsClient) CreateOrUpdateResponder(resp *http.Response) (result PartnerConfiguration, err error) {
   183  	err = autorest.Respond(
   184  		resp,
   185  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   186  		autorest.ByUnmarshallingJSON(&result),
   187  		autorest.ByClosing())
   188  	result.Response = autorest.Response{Response: resp}
   189  	return
   190  }
   191  
   192  // Delete delete existing partner configuration.
   193  // Parameters:
   194  // resourceGroupName - the name of the resource group within the user's subscription.
   195  func (client PartnerConfigurationsClient) Delete(ctx context.Context, resourceGroupName string) (result PartnerConfigurationsDeleteFuture, err error) {
   196  	if tracing.IsEnabled() {
   197  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.Delete")
   198  		defer func() {
   199  			sc := -1
   200  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   201  				sc = result.FutureAPI.Response().StatusCode
   202  			}
   203  			tracing.EndSpan(ctx, sc, err)
   204  		}()
   205  	}
   206  	req, err := client.DeletePreparer(ctx, resourceGroupName)
   207  	if err != nil {
   208  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Delete", nil, "Failure preparing request")
   209  		return
   210  	}
   211  
   212  	result, err = client.DeleteSender(req)
   213  	if err != nil {
   214  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Delete", result.Response(), "Failure sending request")
   215  		return
   216  	}
   217  
   218  	return
   219  }
   220  
   221  // DeletePreparer prepares the Delete request.
   222  func (client PartnerConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   223  	pathParameters := map[string]interface{}{
   224  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   225  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   226  	}
   227  
   228  	const APIVersion = "2021-10-15-preview"
   229  	queryParameters := map[string]interface{}{
   230  		"api-version": APIVersion,
   231  	}
   232  
   233  	preparer := autorest.CreatePreparer(
   234  		autorest.AsDelete(),
   235  		autorest.WithBaseURL(client.BaseURI),
   236  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", pathParameters),
   237  		autorest.WithQueryParameters(queryParameters))
   238  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   239  }
   240  
   241  // DeleteSender sends the Delete request. The method will close the
   242  // http.Response Body if it receives an error.
   243  func (client PartnerConfigurationsClient) DeleteSender(req *http.Request) (future PartnerConfigurationsDeleteFuture, err error) {
   244  	var resp *http.Response
   245  	future.FutureAPI = &azure.Future{}
   246  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   247  	if err != nil {
   248  		return
   249  	}
   250  	var azf azure.Future
   251  	azf, err = azure.NewFutureFromResponse(resp)
   252  	future.FutureAPI = &azf
   253  	future.Result = future.result
   254  	return
   255  }
   256  
   257  // DeleteResponder handles the response to the Delete request. The method always
   258  // closes the http.Response Body.
   259  func (client PartnerConfigurationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   260  	err = autorest.Respond(
   261  		resp,
   262  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   263  		autorest.ByClosing())
   264  	result.Response = resp
   265  	return
   266  }
   267  
   268  // Get get properties of a partner configuration.
   269  // Parameters:
   270  // resourceGroupName - the name of the resource group within the user's subscription.
   271  func (client PartnerConfigurationsClient) Get(ctx context.Context, resourceGroupName string) (result PartnerConfiguration, err error) {
   272  	if tracing.IsEnabled() {
   273  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.Get")
   274  		defer func() {
   275  			sc := -1
   276  			if result.Response.Response != nil {
   277  				sc = result.Response.Response.StatusCode
   278  			}
   279  			tracing.EndSpan(ctx, sc, err)
   280  		}()
   281  	}
   282  	req, err := client.GetPreparer(ctx, resourceGroupName)
   283  	if err != nil {
   284  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Get", nil, "Failure preparing request")
   285  		return
   286  	}
   287  
   288  	resp, err := client.GetSender(req)
   289  	if err != nil {
   290  		result.Response = autorest.Response{Response: resp}
   291  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Get", resp, "Failure sending request")
   292  		return
   293  	}
   294  
   295  	result, err = client.GetResponder(resp)
   296  	if err != nil {
   297  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Get", resp, "Failure responding to request")
   298  		return
   299  	}
   300  
   301  	return
   302  }
   303  
   304  // GetPreparer prepares the Get request.
   305  func (client PartnerConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   306  	pathParameters := map[string]interface{}{
   307  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   308  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   309  	}
   310  
   311  	const APIVersion = "2021-10-15-preview"
   312  	queryParameters := map[string]interface{}{
   313  		"api-version": APIVersion,
   314  	}
   315  
   316  	preparer := autorest.CreatePreparer(
   317  		autorest.AsGet(),
   318  		autorest.WithBaseURL(client.BaseURI),
   319  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", pathParameters),
   320  		autorest.WithQueryParameters(queryParameters))
   321  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   322  }
   323  
   324  // GetSender sends the Get request. The method will close the
   325  // http.Response Body if it receives an error.
   326  func (client PartnerConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
   327  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   328  }
   329  
   330  // GetResponder handles the response to the Get request. The method always
   331  // closes the http.Response Body.
   332  func (client PartnerConfigurationsClient) GetResponder(resp *http.Response) (result PartnerConfiguration, err error) {
   333  	err = autorest.Respond(
   334  		resp,
   335  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   336  		autorest.ByUnmarshallingJSON(&result),
   337  		autorest.ByClosing())
   338  	result.Response = autorest.Response{Response: resp}
   339  	return
   340  }
   341  
   342  // ListByResourceGroup list all the partner configurations under a resource group.
   343  // Parameters:
   344  // resourceGroupName - the name of the resource group within the user's subscription.
   345  func (client PartnerConfigurationsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result PartnerConfigurationsListResult, err error) {
   346  	if tracing.IsEnabled() {
   347  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.ListByResourceGroup")
   348  		defer func() {
   349  			sc := -1
   350  			if result.Response.Response != nil {
   351  				sc = result.Response.Response.StatusCode
   352  			}
   353  			tracing.EndSpan(ctx, sc, err)
   354  		}()
   355  	}
   356  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   357  	if err != nil {
   358  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListByResourceGroup", nil, "Failure preparing request")
   359  		return
   360  	}
   361  
   362  	resp, err := client.ListByResourceGroupSender(req)
   363  	if err != nil {
   364  		result.Response = autorest.Response{Response: resp}
   365  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListByResourceGroup", resp, "Failure sending request")
   366  		return
   367  	}
   368  
   369  	result, err = client.ListByResourceGroupResponder(resp)
   370  	if err != nil {
   371  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListByResourceGroup", resp, "Failure responding to request")
   372  		return
   373  	}
   374  
   375  	return
   376  }
   377  
   378  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   379  func (client PartnerConfigurationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   380  	pathParameters := map[string]interface{}{
   381  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   382  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   383  	}
   384  
   385  	const APIVersion = "2021-10-15-preview"
   386  	queryParameters := map[string]interface{}{
   387  		"api-version": APIVersion,
   388  	}
   389  
   390  	preparer := autorest.CreatePreparer(
   391  		autorest.AsGet(),
   392  		autorest.WithBaseURL(client.BaseURI),
   393  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations", pathParameters),
   394  		autorest.WithQueryParameters(queryParameters))
   395  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   396  }
   397  
   398  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   399  // http.Response Body if it receives an error.
   400  func (client PartnerConfigurationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   401  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   402  }
   403  
   404  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   405  // closes the http.Response Body.
   406  func (client PartnerConfigurationsClient) ListByResourceGroupResponder(resp *http.Response) (result PartnerConfigurationsListResult, err error) {
   407  	err = autorest.Respond(
   408  		resp,
   409  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   410  		autorest.ByUnmarshallingJSON(&result),
   411  		autorest.ByClosing())
   412  	result.Response = autorest.Response{Response: resp}
   413  	return
   414  }
   415  
   416  // ListBySubscription list all the partner configurations under an Azure subscription.
   417  // Parameters:
   418  // filter - the query used to filter the search results using OData syntax. Filtering is permitted on the
   419  // 'name' property only and with limited number of OData operations. These operations are: the 'contains'
   420  // function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal).
   421  // No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE,
   422  // 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq
   423  // 'westus'.
   424  // top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to
   425  // 100. If not specified, the default number of results to be returned is 20 items per page.
   426  func (client PartnerConfigurationsClient) ListBySubscription(ctx context.Context, filter string, top *int32) (result PartnerConfigurationsListResultPage, err error) {
   427  	if tracing.IsEnabled() {
   428  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.ListBySubscription")
   429  		defer func() {
   430  			sc := -1
   431  			if result.pclr.Response.Response != nil {
   432  				sc = result.pclr.Response.Response.StatusCode
   433  			}
   434  			tracing.EndSpan(ctx, sc, err)
   435  		}()
   436  	}
   437  	result.fn = client.listBySubscriptionNextResults
   438  	req, err := client.ListBySubscriptionPreparer(ctx, filter, top)
   439  	if err != nil {
   440  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListBySubscription", nil, "Failure preparing request")
   441  		return
   442  	}
   443  
   444  	resp, err := client.ListBySubscriptionSender(req)
   445  	if err != nil {
   446  		result.pclr.Response = autorest.Response{Response: resp}
   447  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListBySubscription", resp, "Failure sending request")
   448  		return
   449  	}
   450  
   451  	result.pclr, err = client.ListBySubscriptionResponder(resp)
   452  	if err != nil {
   453  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "ListBySubscription", resp, "Failure responding to request")
   454  		return
   455  	}
   456  	if result.pclr.hasNextLink() && result.pclr.IsEmpty() {
   457  		err = result.NextWithContext(ctx)
   458  		return
   459  	}
   460  
   461  	return
   462  }
   463  
   464  // ListBySubscriptionPreparer prepares the ListBySubscription request.
   465  func (client PartnerConfigurationsClient) ListBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
   466  	pathParameters := map[string]interface{}{
   467  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   468  	}
   469  
   470  	const APIVersion = "2021-10-15-preview"
   471  	queryParameters := map[string]interface{}{
   472  		"api-version": APIVersion,
   473  	}
   474  	if len(filter) > 0 {
   475  		queryParameters["$filter"] = autorest.Encode("query", filter)
   476  	}
   477  	if top != nil {
   478  		queryParameters["$top"] = autorest.Encode("query", *top)
   479  	}
   480  
   481  	preparer := autorest.CreatePreparer(
   482  		autorest.AsGet(),
   483  		autorest.WithBaseURL(client.BaseURI),
   484  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations", pathParameters),
   485  		autorest.WithQueryParameters(queryParameters))
   486  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   487  }
   488  
   489  // ListBySubscriptionSender sends the ListBySubscription request. The method will close the
   490  // http.Response Body if it receives an error.
   491  func (client PartnerConfigurationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
   492  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   493  }
   494  
   495  // ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
   496  // closes the http.Response Body.
   497  func (client PartnerConfigurationsClient) ListBySubscriptionResponder(resp *http.Response) (result PartnerConfigurationsListResult, err error) {
   498  	err = autorest.Respond(
   499  		resp,
   500  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   501  		autorest.ByUnmarshallingJSON(&result),
   502  		autorest.ByClosing())
   503  	result.Response = autorest.Response{Response: resp}
   504  	return
   505  }
   506  
   507  // listBySubscriptionNextResults retrieves the next set of results, if any.
   508  func (client PartnerConfigurationsClient) listBySubscriptionNextResults(ctx context.Context, lastResults PartnerConfigurationsListResult) (result PartnerConfigurationsListResult, err error) {
   509  	req, err := lastResults.partnerConfigurationsListResultPreparer(ctx)
   510  	if err != nil {
   511  		return result, autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
   512  	}
   513  	if req == nil {
   514  		return
   515  	}
   516  	resp, err := client.ListBySubscriptionSender(req)
   517  	if err != nil {
   518  		result.Response = autorest.Response{Response: resp}
   519  		return result, autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
   520  	}
   521  	result, err = client.ListBySubscriptionResponder(resp)
   522  	if err != nil {
   523  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
   524  	}
   525  	return
   526  }
   527  
   528  // ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
   529  func (client PartnerConfigurationsClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result PartnerConfigurationsListResultIterator, err error) {
   530  	if tracing.IsEnabled() {
   531  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.ListBySubscription")
   532  		defer func() {
   533  			sc := -1
   534  			if result.Response().Response.Response != nil {
   535  				sc = result.page.Response().Response.Response.StatusCode
   536  			}
   537  			tracing.EndSpan(ctx, sc, err)
   538  		}()
   539  	}
   540  	result.page, err = client.ListBySubscription(ctx, filter, top)
   541  	return
   542  }
   543  
   544  // UnauthorizePartner unauthorize a single partner either by partner registration immutable Id or by partner name.
   545  // Parameters:
   546  // resourceGroupName - the name of the resource group within the user's subscription.
   547  // partnerInfo - the information of the partner to be unauthorized.
   548  func (client PartnerConfigurationsClient) UnauthorizePartner(ctx context.Context, resourceGroupName string, partnerInfo Partner) (result PartnerConfiguration, err error) {
   549  	if tracing.IsEnabled() {
   550  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.UnauthorizePartner")
   551  		defer func() {
   552  			sc := -1
   553  			if result.Response.Response != nil {
   554  				sc = result.Response.Response.StatusCode
   555  			}
   556  			tracing.EndSpan(ctx, sc, err)
   557  		}()
   558  	}
   559  	req, err := client.UnauthorizePartnerPreparer(ctx, resourceGroupName, partnerInfo)
   560  	if err != nil {
   561  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "UnauthorizePartner", nil, "Failure preparing request")
   562  		return
   563  	}
   564  
   565  	resp, err := client.UnauthorizePartnerSender(req)
   566  	if err != nil {
   567  		result.Response = autorest.Response{Response: resp}
   568  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "UnauthorizePartner", resp, "Failure sending request")
   569  		return
   570  	}
   571  
   572  	result, err = client.UnauthorizePartnerResponder(resp)
   573  	if err != nil {
   574  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "UnauthorizePartner", resp, "Failure responding to request")
   575  		return
   576  	}
   577  
   578  	return
   579  }
   580  
   581  // UnauthorizePartnerPreparer prepares the UnauthorizePartner request.
   582  func (client PartnerConfigurationsClient) UnauthorizePartnerPreparer(ctx context.Context, resourceGroupName string, partnerInfo Partner) (*http.Request, error) {
   583  	pathParameters := map[string]interface{}{
   584  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   585  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   586  	}
   587  
   588  	const APIVersion = "2021-10-15-preview"
   589  	queryParameters := map[string]interface{}{
   590  		"api-version": APIVersion,
   591  	}
   592  
   593  	preparer := autorest.CreatePreparer(
   594  		autorest.AsContentType("application/json; charset=utf-8"),
   595  		autorest.AsPost(),
   596  		autorest.WithBaseURL(client.BaseURI),
   597  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner", pathParameters),
   598  		autorest.WithJSON(partnerInfo),
   599  		autorest.WithQueryParameters(queryParameters))
   600  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   601  }
   602  
   603  // UnauthorizePartnerSender sends the UnauthorizePartner request. The method will close the
   604  // http.Response Body if it receives an error.
   605  func (client PartnerConfigurationsClient) UnauthorizePartnerSender(req *http.Request) (*http.Response, error) {
   606  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   607  }
   608  
   609  // UnauthorizePartnerResponder handles the response to the UnauthorizePartner request. The method always
   610  // closes the http.Response Body.
   611  func (client PartnerConfigurationsClient) UnauthorizePartnerResponder(resp *http.Response) (result PartnerConfiguration, err error) {
   612  	err = autorest.Respond(
   613  		resp,
   614  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   615  		autorest.ByUnmarshallingJSON(&result),
   616  		autorest.ByClosing())
   617  	result.Response = autorest.Response{Response: resp}
   618  	return
   619  }
   620  
   621  // Update synchronously updates a partner configuration with the specified parameters.
   622  // Parameters:
   623  // resourceGroupName - the name of the resource group within the user's subscription.
   624  // partnerConfigurationUpdateParameters - partner configuration update information.
   625  func (client PartnerConfigurationsClient) Update(ctx context.Context, resourceGroupName string, partnerConfigurationUpdateParameters PartnerConfigurationUpdateParameters) (result PartnerConfigurationsUpdateFuture, err error) {
   626  	if tracing.IsEnabled() {
   627  		ctx = tracing.StartSpan(ctx, fqdn+"/PartnerConfigurationsClient.Update")
   628  		defer func() {
   629  			sc := -1
   630  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   631  				sc = result.FutureAPI.Response().StatusCode
   632  			}
   633  			tracing.EndSpan(ctx, sc, err)
   634  		}()
   635  	}
   636  	req, err := client.UpdatePreparer(ctx, resourceGroupName, partnerConfigurationUpdateParameters)
   637  	if err != nil {
   638  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Update", nil, "Failure preparing request")
   639  		return
   640  	}
   641  
   642  	result, err = client.UpdateSender(req)
   643  	if err != nil {
   644  		err = autorest.NewErrorWithError(err, "eventgrid.PartnerConfigurationsClient", "Update", result.Response(), "Failure sending request")
   645  		return
   646  	}
   647  
   648  	return
   649  }
   650  
   651  // UpdatePreparer prepares the Update request.
   652  func (client PartnerConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, partnerConfigurationUpdateParameters PartnerConfigurationUpdateParameters) (*http.Request, error) {
   653  	pathParameters := map[string]interface{}{
   654  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   655  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   656  	}
   657  
   658  	const APIVersion = "2021-10-15-preview"
   659  	queryParameters := map[string]interface{}{
   660  		"api-version": APIVersion,
   661  	}
   662  
   663  	preparer := autorest.CreatePreparer(
   664  		autorest.AsContentType("application/json; charset=utf-8"),
   665  		autorest.AsPatch(),
   666  		autorest.WithBaseURL(client.BaseURI),
   667  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", pathParameters),
   668  		autorest.WithJSON(partnerConfigurationUpdateParameters),
   669  		autorest.WithQueryParameters(queryParameters))
   670  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   671  }
   672  
   673  // UpdateSender sends the Update request. The method will close the
   674  // http.Response Body if it receives an error.
   675  func (client PartnerConfigurationsClient) UpdateSender(req *http.Request) (future PartnerConfigurationsUpdateFuture, err error) {
   676  	var resp *http.Response
   677  	future.FutureAPI = &azure.Future{}
   678  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   679  	if err != nil {
   680  		return
   681  	}
   682  	var azf azure.Future
   683  	azf, err = azure.NewFutureFromResponse(resp)
   684  	future.FutureAPI = &azf
   685  	future.Result = future.result
   686  	return
   687  }
   688  
   689  // UpdateResponder handles the response to the Update request. The method always
   690  // closes the http.Response Body.
   691  func (client PartnerConfigurationsClient) UpdateResponder(resp *http.Response) (result PartnerConfiguration, err error) {
   692  	err = autorest.Respond(
   693  		resp,
   694  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   695  		autorest.ByUnmarshallingJSON(&result),
   696  		autorest.ByClosing())
   697  	result.Response = autorest.Response{Response: resp}
   698  	return
   699  }
   700  

View as plain text