...

Source file src/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2021-03-31/devices/privatelinkresources.go

Documentation: github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2021-03-31/devices

     1  package devices
     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  // PrivateLinkResourcesClient is the use this API to manage the IoT hubs in your Azure subscription.
    18  type PrivateLinkResourcesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client.
    23  func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient {
    24  	return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom
    28  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    29  // stack).
    30  func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient {
    31  	return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Get get the specified private link resource for the given IotHub
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group that contains the IoT hub.
    37  // resourceName - the name of the IoT hub.
    38  // groupID - the name of the private link resource
    39  func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (result GroupIDInformation, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupID)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	resp, err := client.GetSender(req)
    57  	if err != nil {
    58  		result.Response = autorest.Response{Response: resp}
    59  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "Get", resp, "Failure sending request")
    60  		return
    61  	}
    62  
    63  	result, err = client.GetResponder(resp)
    64  	if err != nil {
    65  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request")
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // GetPreparer prepares the Get request.
    73  func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (*http.Request, error) {
    74  	pathParameters := map[string]interface{}{
    75  		"groupId":           autorest.Encode("path", groupID),
    76  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    77  		"resourceName":      autorest.Encode("path", resourceName),
    78  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    79  	}
    80  
    81  	const APIVersion = "2021-03-31"
    82  	queryParameters := map[string]interface{}{
    83  		"api-version": APIVersion,
    84  	}
    85  
    86  	preparer := autorest.CreatePreparer(
    87  		autorest.AsGet(),
    88  		autorest.WithBaseURL(client.BaseURI),
    89  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", pathParameters),
    90  		autorest.WithQueryParameters(queryParameters))
    91  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    92  }
    93  
    94  // GetSender sends the Get request. The method will close the
    95  // http.Response Body if it receives an error.
    96  func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) {
    97  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  }
    99  
   100  // GetResponder handles the response to the Get request. The method always
   101  // closes the http.Response Body.
   102  func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result GroupIDInformation, err error) {
   103  	err = autorest.Respond(
   104  		resp,
   105  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   106  		autorest.ByUnmarshallingJSON(&result),
   107  		autorest.ByClosing())
   108  	result.Response = autorest.Response{Response: resp}
   109  	return
   110  }
   111  
   112  // List list private link resources for the given IotHub
   113  // Parameters:
   114  // resourceGroupName - the name of the resource group that contains the IoT hub.
   115  // resourceName - the name of the IoT hub.
   116  func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResources, err error) {
   117  	if tracing.IsEnabled() {
   118  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List")
   119  		defer func() {
   120  			sc := -1
   121  			if result.Response.Response != nil {
   122  				sc = result.Response.Response.StatusCode
   123  			}
   124  			tracing.EndSpan(ctx, sc, err)
   125  		}()
   126  	}
   127  	req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
   128  	if err != nil {
   129  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "List", nil, "Failure preparing request")
   130  		return
   131  	}
   132  
   133  	resp, err := client.ListSender(req)
   134  	if err != nil {
   135  		result.Response = autorest.Response{Response: resp}
   136  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "List", resp, "Failure sending request")
   137  		return
   138  	}
   139  
   140  	result, err = client.ListResponder(resp)
   141  	if err != nil {
   142  		err = autorest.NewErrorWithError(err, "devices.PrivateLinkResourcesClient", "List", resp, "Failure responding to request")
   143  		return
   144  	}
   145  
   146  	return
   147  }
   148  
   149  // ListPreparer prepares the List request.
   150  func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
   151  	pathParameters := map[string]interface{}{
   152  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   153  		"resourceName":      autorest.Encode("path", resourceName),
   154  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   155  	}
   156  
   157  	const APIVersion = "2021-03-31"
   158  	queryParameters := map[string]interface{}{
   159  		"api-version": APIVersion,
   160  	}
   161  
   162  	preparer := autorest.CreatePreparer(
   163  		autorest.AsGet(),
   164  		autorest.WithBaseURL(client.BaseURI),
   165  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", pathParameters),
   166  		autorest.WithQueryParameters(queryParameters))
   167  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   168  }
   169  
   170  // ListSender sends the List request. The method will close the
   171  // http.Response Body if it receives an error.
   172  func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) {
   173  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   174  }
   175  
   176  // ListResponder handles the response to the List request. The method always
   177  // closes the http.Response Body.
   178  func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResources, err error) {
   179  	err = autorest.Respond(
   180  		resp,
   181  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   182  		autorest.ByUnmarshallingJSON(&result),
   183  		autorest.ByClosing())
   184  	result.Response = autorest.Response{Response: resp}
   185  	return
   186  }
   187  

View as plain text