1package media 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 9import ( 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 client for the PrivateLinkResources methods of the Media service. 18type PrivateLinkResourcesClient struct { 19 BaseClient 20} 21 22// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. 23func 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). 30func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { 31 return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Get get group ID. 35// Parameters: 36// resourceGroupName - the name of the resource group within the Azure subscription. 37// accountName - the Media Services account name. 38func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string) (result PrivateLinkResource, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") 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.GetPreparer(ctx, resourceGroupName, accountName, name) 50 if err != nil { 51 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") 52 return 53 } 54 55 resp, err := client.GetSender(req) 56 if err != nil { 57 result.Response = autorest.Response{Response: resp} 58 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") 59 return 60 } 61 62 result, err = client.GetResponder(resp) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") 65 return 66 } 67 68 return 69} 70 71// GetPreparer prepares the Get request. 72func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, name string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "accountName": autorest.Encode("path", accountName), 75 "name": autorest.Encode("path", name), 76 "resourceGroupName": autorest.Encode("path", resourceGroupName), 77 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 78 } 79 80 const APIVersion = "2021-06-01" 81 queryParameters := map[string]interface{}{ 82 "api-version": APIVersion, 83 } 84 85 preparer := autorest.CreatePreparer( 86 autorest.AsGet(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources/{name}", pathParameters), 89 autorest.WithQueryParameters(queryParameters)) 90 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 91} 92 93// GetSender sends the Get request. The method will close the 94// http.Response Body if it receives an error. 95func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { 96 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 97} 98 99// GetResponder handles the response to the Get request. The method always 100// closes the http.Response Body. 101func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, 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// List get list of group IDs. 112// Parameters: 113// resourceGroupName - the name of the resource group within the Azure subscription. 114// accountName - the Media Services account name. 115func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListResult, err error) { 116 if tracing.IsEnabled() { 117 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") 118 defer func() { 119 sc := -1 120 if result.Response.Response != nil { 121 sc = result.Response.Response.StatusCode 122 } 123 tracing.EndSpan(ctx, sc, err) 124 }() 125 } 126 req, err := client.ListPreparer(ctx, resourceGroupName, accountName) 127 if err != nil { 128 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") 129 return 130 } 131 132 resp, err := client.ListSender(req) 133 if err != nil { 134 result.Response = autorest.Response{Response: resp} 135 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "List", resp, "Failure sending request") 136 return 137 } 138 139 result, err = client.ListResponder(resp) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "media.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") 142 return 143 } 144 145 return 146} 147 148// ListPreparer prepares the List request. 149func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 150 pathParameters := map[string]interface{}{ 151 "accountName": autorest.Encode("path", accountName), 152 "resourceGroupName": autorest.Encode("path", resourceGroupName), 153 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 154 } 155 156 const APIVersion = "2021-06-01" 157 queryParameters := map[string]interface{}{ 158 "api-version": APIVersion, 159 } 160 161 preparer := autorest.CreatePreparer( 162 autorest.AsGet(), 163 autorest.WithBaseURL(client.BaseURI), 164 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/privateLinkResources", pathParameters), 165 autorest.WithQueryParameters(queryParameters)) 166 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 167} 168 169// ListSender sends the List request. The method will close the 170// http.Response Body if it receives an error. 171func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { 172 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 173} 174 175// ListResponder handles the response to the List request. The method always 176// closes the http.Response Body. 177func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { 178 err = autorest.Respond( 179 resp, 180 azure.WithErrorUnlessStatusCode(http.StatusOK), 181 autorest.ByUnmarshallingJSON(&result), 182 autorest.ByClosing()) 183 result.Response = autorest.Response{Response: resp} 184 return 185} 186