github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/applicationgatewaywafdynamicmanifestsdefault_client.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // Licensed under the MIT License. See License.txt in the project root for license information. 6 // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. 7 // Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9 package armnetwork 10 11 import ( 12 "context" 13 "errors" 14 "github.com/Azure/azure-sdk-for-go/sdk/azcore" 15 "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" 16 "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" 17 "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" 18 "net/http" 19 "net/url" 20 "strings" 21 ) 22 23 // ApplicationGatewayWafDynamicManifestsDefaultClient contains the methods for the ApplicationGatewayWafDynamicManifestsDefault group. 24 // Don't use this type directly, use NewApplicationGatewayWafDynamicManifestsDefaultClient() instead. 25 type ApplicationGatewayWafDynamicManifestsDefaultClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewApplicationGatewayWafDynamicManifestsDefaultClient creates a new instance of ApplicationGatewayWafDynamicManifestsDefaultClient with the specified values. 31 // - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription 32 // ID forms part of the URI for every service call. 33 // - credential - used to authorize requests. Usually a credential from azidentity. 34 // - options - pass nil to accept the default values. 35 func NewApplicationGatewayWafDynamicManifestsDefaultClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationGatewayWafDynamicManifestsDefaultClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &ApplicationGatewayWafDynamicManifestsDefaultClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // Get - Gets the regional application gateway waf manifest. 48 // If the operation fails it returns an *azcore.ResponseError type. 49 // 50 // Generated from API version 2024-05-01 51 // - location - The region where the nrp are located at. 52 // - options - ApplicationGatewayWafDynamicManifestsDefaultClientGetOptions contains the optional parameters for the ApplicationGatewayWafDynamicManifestsDefaultClient.Get 53 // method. 54 func (client *ApplicationGatewayWafDynamicManifestsDefaultClient) Get(ctx context.Context, location string, options *ApplicationGatewayWafDynamicManifestsDefaultClientGetOptions) (ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse, error) { 55 var err error 56 const operationName = "ApplicationGatewayWafDynamicManifestsDefaultClient.Get" 57 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 58 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 59 defer func() { endSpan(err) }() 60 req, err := client.getCreateRequest(ctx, location, options) 61 if err != nil { 62 return ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse{}, err 63 } 64 httpResp, err := client.internal.Pipeline().Do(req) 65 if err != nil { 66 return ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse{}, err 67 } 68 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 69 err = runtime.NewResponseError(httpResp) 70 return ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse{}, err 71 } 72 resp, err := client.getHandleResponse(httpResp) 73 return resp, err 74 } 75 76 // getCreateRequest creates the Get request. 77 func (client *ApplicationGatewayWafDynamicManifestsDefaultClient) getCreateRequest(ctx context.Context, location string, options *ApplicationGatewayWafDynamicManifestsDefaultClientGetOptions) (*policy.Request, error) { 78 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/applicationGatewayWafDynamicManifests/dafault" 79 if location == "" { 80 return nil, errors.New("parameter location cannot be empty") 81 } 82 urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) 83 if client.subscriptionID == "" { 84 return nil, errors.New("parameter client.subscriptionID cannot be empty") 85 } 86 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 87 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 88 if err != nil { 89 return nil, err 90 } 91 reqQP := req.Raw().URL.Query() 92 reqQP.Set("api-version", "2024-05-01") 93 req.Raw().URL.RawQuery = reqQP.Encode() 94 req.Raw().Header["Accept"] = []string{"application/json"} 95 return req, nil 96 } 97 98 // getHandleResponse handles the Get response. 99 func (client *ApplicationGatewayWafDynamicManifestsDefaultClient) getHandleResponse(resp *http.Response) (ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse, error) { 100 result := ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse{} 101 if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationGatewayWafDynamicManifestResult); err != nil { 102 return ApplicationGatewayWafDynamicManifestsDefaultClientGetResponse{}, err 103 } 104 return result, nil 105 }