-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathbinaryhardening_client.go
More file actions
124 lines (117 loc) · 5.61 KB
/
Copy pathbinaryhardening_client.go
File metadata and controls
124 lines (117 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT.
package armiotfirmwaredefense
import (
"context"
"errors"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"net/http"
"net/url"
"strings"
)
// BinaryHardeningClient contains the methods for the BinaryHardening group.
// Don't use this type directly, use NewBinaryHardeningClient() instead.
//
// Generated from API version 2026-06-01-preview
type BinaryHardeningClient struct {
internal *arm.Client
subscriptionID string
}
// NewBinaryHardeningClient creates a new instance of BinaryHardeningClient with the specified values.
// - subscriptionID - The ID of the target subscription. The value must be an UUID.
// - credential - used to authorize requests. Usually a credential from azidentity.
// - options - Contains optional client configuration. Pass nil to accept the default values.
func NewBinaryHardeningClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BinaryHardeningClient, error) {
cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
if err != nil {
return nil, err
}
client := &BinaryHardeningClient{
subscriptionID: subscriptionID,
internal: cl,
}
return client, nil
}
// NewListByFirmwarePager - Lists binary hardening analysis results of a firmware.
// - resourceGroupName - The name of the resource group. The name is case insensitive.
// - workspaceName - The name of the firmware analysis workspace.
// - firmwareID - The id of the firmware.
// - options - BinaryHardeningClientListByFirmwareOptions contains the optional parameters for the BinaryHardeningClient.NewListByFirmwarePager
// method.
func (client *BinaryHardeningClient) NewListByFirmwarePager(resourceGroupName string, workspaceName string, firmwareID string, options *BinaryHardeningClientListByFirmwareOptions) *runtime.Pager[BinaryHardeningClientListByFirmwareResponse] {
return runtime.NewPager(runtime.PagingHandler[BinaryHardeningClientListByFirmwareResponse]{
More: func(page BinaryHardeningClientListByFirmwareResponse) bool {
return page.NextLink != nil && len(*page.NextLink) > 0
},
Fetcher: func(ctx context.Context, page *BinaryHardeningClientListByFirmwareResponse) (BinaryHardeningClientListByFirmwareResponse, error) {
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BinaryHardeningClient.NewListByFirmwarePager")
nextLink := ""
if page != nil {
nextLink = *page.NextLink
}
req, err := client.listByFirmwareCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, nextLink, options)
if err != nil {
return BinaryHardeningClientListByFirmwareResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return BinaryHardeningClientListByFirmwareResponse{}, err
}
return client.listByFirmwareHandleResponse(resp, http.StatusOK)
},
Tracer: client.internal.Tracer(),
})
}
// listByFirmwareCreateRequest creates the ListByFirmware request.
func (client *BinaryHardeningClient) listByFirmwareCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, nextLink string, _ *BinaryHardeningClientListByFirmwareOptions) (*policy.Request, error) {
firstPage := nextLink == ""
var req *policy.Request
var err error
if firstPage {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/binaryHardeningResults"
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if workspaceName == "" {
return nil, errors.New("parameter workspaceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName))
if firmwareID == "" {
return nil, errors.New("parameter firmwareID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{firmwareId}", url.PathEscape(firmwareID))
req, err = runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
} else {
req, err = runtime.NewRequestForNextLink(ctx, http.MethodGet, client.internal.Endpoint(), nextLink)
}
if err != nil {
return nil, err
}
if firstPage {
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", version20260601Preview)
req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
req.Raw().Header["Accept"] = []string{"application/json"}
}
return req, nil
}
// listByFirmwareHandleResponse handles the ListByFirmware response.
func (client *BinaryHardeningClient) listByFirmwareHandleResponse(resp *http.Response, successCodes ...int) (BinaryHardeningClientListByFirmwareResponse, error) {
result := BinaryHardeningClientListByFirmwareResponse{}
if !runtime.HasStatusCode(resp, successCodes...) {
return result, runtime.NewResponseError(resp)
}
if err := runtime.UnmarshalAsJSON(resp, &result.BinaryHardeningResourceListResult); err != nil {
return BinaryHardeningClientListByFirmwareResponse{}, err
}
return result, nil
}