github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/managerdeploymentstatus_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 "strconv" 21 "strings" 22 ) 23 24 // ManagerDeploymentStatusClient contains the methods for the NetworkManagerDeploymentStatus group. 25 // Don't use this type directly, use NewManagerDeploymentStatusClient() instead. 26 type ManagerDeploymentStatusClient struct { 27 internal *arm.Client 28 subscriptionID string 29 } 30 31 // NewManagerDeploymentStatusClient creates a new instance of ManagerDeploymentStatusClient with the specified values. 32 // - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription 33 // ID forms part of the URI for every service call. 34 // - credential - used to authorize requests. Usually a credential from azidentity. 35 // - options - pass nil to accept the default values. 36 func NewManagerDeploymentStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagerDeploymentStatusClient, error) { 37 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 38 if err != nil { 39 return nil, err 40 } 41 client := &ManagerDeploymentStatusClient{ 42 subscriptionID: subscriptionID, 43 internal: cl, 44 } 45 return client, nil 46 } 47 48 // List - Post to List of Network Manager Deployment Status. 49 // If the operation fails it returns an *azcore.ResponseError type. 50 // 51 // Generated from API version 2024-05-01 52 // - resourceGroupName - The name of the resource group. 53 // - networkManagerName - The name of the network manager. 54 // - parameters - Parameters supplied to specify which Managed Network deployment status is. 55 // - options - ManagerDeploymentStatusClientListOptions contains the optional parameters for the ManagerDeploymentStatusClient.List 56 // method. 57 func (client *ManagerDeploymentStatusClient) List(ctx context.Context, resourceGroupName string, networkManagerName string, parameters ManagerDeploymentStatusParameter, options *ManagerDeploymentStatusClientListOptions) (ManagerDeploymentStatusClientListResponse, error) { 58 var err error 59 const operationName = "ManagerDeploymentStatusClient.List" 60 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 61 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 62 defer func() { endSpan(err) }() 63 req, err := client.listCreateRequest(ctx, resourceGroupName, networkManagerName, parameters, options) 64 if err != nil { 65 return ManagerDeploymentStatusClientListResponse{}, err 66 } 67 httpResp, err := client.internal.Pipeline().Do(req) 68 if err != nil { 69 return ManagerDeploymentStatusClientListResponse{}, err 70 } 71 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 72 err = runtime.NewResponseError(httpResp) 73 return ManagerDeploymentStatusClientListResponse{}, err 74 } 75 resp, err := client.listHandleResponse(httpResp) 76 return resp, err 77 } 78 79 // listCreateRequest creates the List request. 80 func (client *ManagerDeploymentStatusClient) listCreateRequest(ctx context.Context, resourceGroupName string, networkManagerName string, parameters ManagerDeploymentStatusParameter, options *ManagerDeploymentStatusClientListOptions) (*policy.Request, error) { 81 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/listDeploymentStatus" 82 if client.subscriptionID == "" { 83 return nil, errors.New("parameter client.subscriptionID cannot be empty") 84 } 85 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 86 if resourceGroupName == "" { 87 return nil, errors.New("parameter resourceGroupName cannot be empty") 88 } 89 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 90 if networkManagerName == "" { 91 return nil, errors.New("parameter networkManagerName cannot be empty") 92 } 93 urlPath = strings.ReplaceAll(urlPath, "{networkManagerName}", url.PathEscape(networkManagerName)) 94 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 95 if err != nil { 96 return nil, err 97 } 98 reqQP := req.Raw().URL.Query() 99 if options != nil && options.Top != nil { 100 reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) 101 } 102 reqQP.Set("api-version", "2024-05-01") 103 req.Raw().URL.RawQuery = reqQP.Encode() 104 req.Raw().Header["Accept"] = []string{"application/json"} 105 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 106 return nil, err 107 } 108 return req, nil 109 } 110 111 // listHandleResponse handles the List response. 112 func (client *ManagerDeploymentStatusClient) listHandleResponse(resp *http.Response) (ManagerDeploymentStatusClientListResponse, error) { 113 result := ManagerDeploymentStatusClientListResponse{} 114 if err := runtime.UnmarshalAsJSON(resp, &result.ManagerDeploymentStatusListResult); err != nil { 115 return ManagerDeploymentStatusClientListResponse{}, err 116 } 117 return result, nil 118 }