diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/CHANGELOG.md b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/CHANGELOG.md new file mode 100644 index 000000000000..ea4daf27144a --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-07-28) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/LICENSE.txt b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/README.md b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/README.md new file mode 100644 index 000000000000..a8934e3ee97a --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/README.md @@ -0,0 +1,85 @@ +# Azure Iotfirmwaredefense Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense) + +The `armiotfirmwaredefense` module provides operations for working with Azure Iotfirmwaredefense. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Iotfirmwaredefense module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Iotfirmwaredefense. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Iotfirmwaredefense module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armiotfirmwaredefense.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armiotfirmwaredefense.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewFirmwareClient() +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Iotfirmwaredefense` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/autorest.md b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/autorest.md new file mode 100644 index 000000000000..96e6183f392f --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +tag: package-2023-02-08-preview +``` \ No newline at end of file diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/build.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/build.go new file mode 100644 index 000000000000..18ae36ff151c --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/iotfirmwaredefense/armiotfirmwaredefense + +package armiotfirmwaredefense diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/ci.yml b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/ci.yml new file mode 100644 index 000000000000..16ddd7135324 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/iotfirmwaredefense/armiotfirmwaredefense' diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/client_factory.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/client_factory.go new file mode 100644 index 000000000000..dba724a6b189 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/client_factory.go @@ -0,0 +1,54 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewFirmwareClient() *FirmwareClient { + subClient, _ := NewFirmwareClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspacesClient() *WorkspacesClient { + subClient, _ := NewWorkspacesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/constants.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/constants.go new file mode 100644 index 000000000000..9fb4aad1c67d --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/constants.go @@ -0,0 +1,270 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +const ( + moduleName = "armiotfirmwaredefense" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CanaryFlag - Canary flag. +type CanaryFlag string + +const ( + CanaryFlagFalse CanaryFlag = "False" + CanaryFlagTrue CanaryFlag = "True" +) + +// PossibleCanaryFlagValues returns the possible values for the CanaryFlag const type. +func PossibleCanaryFlagValues() []CanaryFlag { + return []CanaryFlag{ + CanaryFlagFalse, + CanaryFlagTrue, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// IsExpired - Indicates if the certificate is expired. +type IsExpired string + +const ( + IsExpiredFalse IsExpired = "False" + IsExpiredTrue IsExpired = "True" +) + +// PossibleIsExpiredValues returns the possible values for the IsExpired const type. +func PossibleIsExpiredValues() []IsExpired { + return []IsExpired{ + IsExpiredFalse, + IsExpiredTrue, + } +} + +// IsSelfSigned - Indicates if the certificate was self-signed. +type IsSelfSigned string + +const ( + IsSelfSignedFalse IsSelfSigned = "False" + IsSelfSignedTrue IsSelfSigned = "True" +) + +// PossibleIsSelfSignedValues returns the possible values for the IsSelfSigned const type. +func PossibleIsSelfSignedValues() []IsSelfSigned { + return []IsSelfSigned{ + IsSelfSignedFalse, + IsSelfSignedTrue, + } +} + +// IsShortKeySize - Indicates the key size is considered too small to be secure for the algorithm. +type IsShortKeySize string + +const ( + IsShortKeySizeFalse IsShortKeySize = "False" + IsShortKeySizeTrue IsShortKeySize = "True" +) + +// PossibleIsShortKeySizeValues returns the possible values for the IsShortKeySize const type. +func PossibleIsShortKeySizeValues() []IsShortKeySize { + return []IsShortKeySize{ + IsShortKeySizeFalse, + IsShortKeySizeTrue, + } +} + +// IsUpdateAvailable - Flag if new update is available for the component. +type IsUpdateAvailable string + +const ( + IsUpdateAvailableFalse IsUpdateAvailable = "False" + IsUpdateAvailableTrue IsUpdateAvailable = "True" +) + +// PossibleIsUpdateAvailableValues returns the possible values for the IsUpdateAvailable const type. +func PossibleIsUpdateAvailableValues() []IsUpdateAvailable { + return []IsUpdateAvailable{ + IsUpdateAvailableFalse, + IsUpdateAvailableTrue, + } +} + +// IsWeakSignature - Indicates the signature algorithm used is insecure. +type IsWeakSignature string + +const ( + IsWeakSignatureFalse IsWeakSignature = "False" + IsWeakSignatureTrue IsWeakSignature = "True" +) + +// PossibleIsWeakSignatureValues returns the possible values for the IsWeakSignature const type. +func PossibleIsWeakSignatureValues() []IsWeakSignature { + return []IsWeakSignature{ + IsWeakSignatureFalse, + IsWeakSignatureTrue, + } +} + +// NxFlag - NX flag. +type NxFlag string + +const ( + NxFlagFalse NxFlag = "False" + NxFlagTrue NxFlag = "True" +) + +// PossibleNxFlagValues returns the possible values for the NxFlag const type. +func PossibleNxFlagValues() []NxFlag { + return []NxFlag{ + NxFlagFalse, + NxFlagTrue, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// PieFlag - PIE flag. +type PieFlag string + +const ( + PieFlagFalse PieFlag = "False" + PieFlagTrue PieFlag = "True" +) + +// PossiblePieFlagValues returns the possible values for the PieFlag const type. +func PossiblePieFlagValues() []PieFlag { + return []PieFlag{ + PieFlagFalse, + PieFlagTrue, + } +} + +// ProvisioningState - Provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// RelroFlag - RELRO flag. +type RelroFlag string + +const ( + RelroFlagFalse RelroFlag = "False" + RelroFlagTrue RelroFlag = "True" +) + +// PossibleRelroFlagValues returns the possible values for the RelroFlag const type. +func PossibleRelroFlagValues() []RelroFlag { + return []RelroFlag{ + RelroFlagFalse, + RelroFlagTrue, + } +} + +// Status - The status of firmware scan. +type Status string + +const ( + StatusAnalyzing Status = "Analyzing" + StatusError Status = "Error" + StatusExtracting Status = "Extracting" + StatusPending Status = "Pending" + StatusReady Status = "Ready" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusAnalyzing, + StatusError, + StatusExtracting, + StatusPending, + StatusReady, + } +} + +// StrippedFlag - Stripped flag. +type StrippedFlag string + +const ( + StrippedFlagFalse StrippedFlag = "False" + StrippedFlagTrue StrippedFlag = "True" +) + +// PossibleStrippedFlagValues returns the possible values for the StrippedFlag const type. +func PossibleStrippedFlagValues() []StrippedFlag { + return []StrippedFlag{ + StrippedFlagFalse, + StrippedFlagTrue, + } +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client.go new file mode 100644 index 000000000000..e0fd9c26f3dc --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client.go @@ -0,0 +1,1375 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// 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" +) + +// FirmwareClient contains the methods for the Firmware group. +// Don't use this type directly, use NewFirmwareClient() instead. +type FirmwareClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFirmwareClient creates a new instance of FirmwareClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFirmwareClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FirmwareClient, error) { + cl, err := arm.NewClient(moduleName+".FirmwareClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FirmwareClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Create - The operation to create a firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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. +// - firmware - Details of the firmware being created or updated. +// - options - FirmwareClientCreateOptions contains the optional parameters for the FirmwareClient.Create method. +func (client *FirmwareClient) Create(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, firmware Firmware, options *FirmwareClientCreateOptions) (FirmwareClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, firmware, options) + if err != nil { + return FirmwareClientCreateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return FirmwareClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *FirmwareClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, firmware Firmware, options *FirmwareClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}" + 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, firmware) +} + +// createHandleResponse handles the Create response. +func (client *FirmwareClient) createHandleResponse(resp *http.Response) (FirmwareClientCreateResponse, error) { + result := FirmwareClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Firmware); err != nil { + return FirmwareClientCreateResponse{}, err + } + return result, nil +} + +// Delete - The operation to delete a firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientDeleteOptions contains the optional parameters for the FirmwareClient.Delete method. +func (client *FirmwareClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientDeleteOptions) (FirmwareClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientDeleteResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return FirmwareClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return FirmwareClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FirmwareClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}" + 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GenerateBinaryHardeningDetails - The operation to get binary hardening details for a firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateBinaryHardeningDetailsOptions contains the optional parameters for the FirmwareClient.GenerateBinaryHardeningDetails +// method. +func (client *FirmwareClient) GenerateBinaryHardeningDetails(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateBinaryHardeningDetailsOptions) (FirmwareClientGenerateBinaryHardeningDetailsResponse, error) { + req, err := client.generateBinaryHardeningDetailsCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateBinaryHardeningDetailsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateBinaryHardeningDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateBinaryHardeningDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.generateBinaryHardeningDetailsHandleResponse(resp) +} + +// generateBinaryHardeningDetailsCreateRequest creates the GenerateBinaryHardeningDetails request. +func (client *FirmwareClient) generateBinaryHardeningDetailsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateBinaryHardeningDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateBinaryHardeningDetails" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateBinaryHardeningDetailsHandleResponse handles the GenerateBinaryHardeningDetails response. +func (client *FirmwareClient) generateBinaryHardeningDetailsHandleResponse(resp *http.Response) (FirmwareClientGenerateBinaryHardeningDetailsResponse, error) { + result := FirmwareClientGenerateBinaryHardeningDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BinaryHardening); err != nil { + return FirmwareClientGenerateBinaryHardeningDetailsResponse{}, err + } + return result, nil +} + +// GenerateBinaryHardeningSummary - The operation to list the binary hardening summary percentages for a firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateBinaryHardeningSummaryOptions contains the optional parameters for the FirmwareClient.GenerateBinaryHardeningSummary +// method. +func (client *FirmwareClient) GenerateBinaryHardeningSummary(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateBinaryHardeningSummaryOptions) (FirmwareClientGenerateBinaryHardeningSummaryResponse, error) { + req, err := client.generateBinaryHardeningSummaryCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateBinaryHardeningSummaryResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateBinaryHardeningSummaryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateBinaryHardeningSummaryResponse{}, runtime.NewResponseError(resp) + } + return client.generateBinaryHardeningSummaryHandleResponse(resp) +} + +// generateBinaryHardeningSummaryCreateRequest creates the GenerateBinaryHardeningSummary request. +func (client *FirmwareClient) generateBinaryHardeningSummaryCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateBinaryHardeningSummaryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateBinaryHardeningSummary" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateBinaryHardeningSummaryHandleResponse handles the GenerateBinaryHardeningSummary response. +func (client *FirmwareClient) generateBinaryHardeningSummaryHandleResponse(resp *http.Response) (FirmwareClientGenerateBinaryHardeningSummaryResponse, error) { + result := FirmwareClientGenerateBinaryHardeningSummaryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BinaryHardeningSummary); err != nil { + return FirmwareClientGenerateBinaryHardeningSummaryResponse{}, err + } + return result, nil +} + +// GenerateComponentDetails - The operation to get component details for a firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateComponentDetailsOptions contains the optional parameters for the FirmwareClient.GenerateComponentDetails +// method. +func (client *FirmwareClient) GenerateComponentDetails(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateComponentDetailsOptions) (FirmwareClientGenerateComponentDetailsResponse, error) { + req, err := client.generateComponentDetailsCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateComponentDetailsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateComponentDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateComponentDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.generateComponentDetailsHandleResponse(resp) +} + +// generateComponentDetailsCreateRequest creates the GenerateComponentDetails request. +func (client *FirmwareClient) generateComponentDetailsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateComponentDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateComponentDetails" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateComponentDetailsHandleResponse handles the GenerateComponentDetails response. +func (client *FirmwareClient) generateComponentDetailsHandleResponse(resp *http.Response) (FirmwareClientGenerateComponentDetailsResponse, error) { + result := FirmwareClientGenerateComponentDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Component); err != nil { + return FirmwareClientGenerateComponentDetailsResponse{}, err + } + return result, nil +} + +// GenerateCryptoCertificateSummary - The operation to provide a high level summary of the discovered cryptographic certificates +// reported for the firmware image. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateCryptoCertificateSummaryOptions contains the optional parameters for the FirmwareClient.GenerateCryptoCertificateSummary +// method. +func (client *FirmwareClient) GenerateCryptoCertificateSummary(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCryptoCertificateSummaryOptions) (FirmwareClientGenerateCryptoCertificateSummaryResponse, error) { + req, err := client.generateCryptoCertificateSummaryCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateCryptoCertificateSummaryResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateCryptoCertificateSummaryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateCryptoCertificateSummaryResponse{}, runtime.NewResponseError(resp) + } + return client.generateCryptoCertificateSummaryHandleResponse(resp) +} + +// generateCryptoCertificateSummaryCreateRequest creates the GenerateCryptoCertificateSummary request. +func (client *FirmwareClient) generateCryptoCertificateSummaryCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCryptoCertificateSummaryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCryptoCertificateSummary" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateCryptoCertificateSummaryHandleResponse handles the GenerateCryptoCertificateSummary response. +func (client *FirmwareClient) generateCryptoCertificateSummaryHandleResponse(resp *http.Response) (FirmwareClientGenerateCryptoCertificateSummaryResponse, error) { + result := FirmwareClientGenerateCryptoCertificateSummaryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CryptoCertificateSummary); err != nil { + return FirmwareClientGenerateCryptoCertificateSummaryResponse{}, err + } + return result, nil +} + +// GenerateCryptoKeySummary - The operation to provide a high level summary of the discovered cryptographic keys reported +// for the firmware image. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateCryptoKeySummaryOptions contains the optional parameters for the FirmwareClient.GenerateCryptoKeySummary +// method. +func (client *FirmwareClient) GenerateCryptoKeySummary(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCryptoKeySummaryOptions) (FirmwareClientGenerateCryptoKeySummaryResponse, error) { + req, err := client.generateCryptoKeySummaryCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateCryptoKeySummaryResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateCryptoKeySummaryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateCryptoKeySummaryResponse{}, runtime.NewResponseError(resp) + } + return client.generateCryptoKeySummaryHandleResponse(resp) +} + +// generateCryptoKeySummaryCreateRequest creates the GenerateCryptoKeySummary request. +func (client *FirmwareClient) generateCryptoKeySummaryCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCryptoKeySummaryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCryptoKeySummary" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateCryptoKeySummaryHandleResponse handles the GenerateCryptoKeySummary response. +func (client *FirmwareClient) generateCryptoKeySummaryHandleResponse(resp *http.Response) (FirmwareClientGenerateCryptoKeySummaryResponse, error) { + result := FirmwareClientGenerateCryptoKeySummaryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CryptoKeySummary); err != nil { + return FirmwareClientGenerateCryptoKeySummaryResponse{}, err + } + return result, nil +} + +// GenerateCveSummary - The operation to provide a high level summary of the CVEs reported for the firmware image. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateCveSummaryOptions contains the optional parameters for the FirmwareClient.GenerateCveSummary +// method. +func (client *FirmwareClient) GenerateCveSummary(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCveSummaryOptions) (FirmwareClientGenerateCveSummaryResponse, error) { + req, err := client.generateCveSummaryCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateCveSummaryResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateCveSummaryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateCveSummaryResponse{}, runtime.NewResponseError(resp) + } + return client.generateCveSummaryHandleResponse(resp) +} + +// generateCveSummaryCreateRequest creates the GenerateCveSummary request. +func (client *FirmwareClient) generateCveSummaryCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateCveSummaryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCveSummary" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateCveSummaryHandleResponse handles the GenerateCveSummary response. +func (client *FirmwareClient) generateCveSummaryHandleResponse(resp *http.Response) (FirmwareClientGenerateCveSummaryResponse, error) { + result := FirmwareClientGenerateCveSummaryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CveSummary); err != nil { + return FirmwareClientGenerateCveSummaryResponse{}, err + } + return result, nil +} + +// GenerateDownloadURL - The operation to a url for file download. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateDownloadURLOptions contains the optional parameters for the FirmwareClient.GenerateDownloadURL +// method. +func (client *FirmwareClient) GenerateDownloadURL(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateDownloadURLOptions) (FirmwareClientGenerateDownloadURLResponse, error) { + req, err := client.generateDownloadURLCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateDownloadURLResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateDownloadURLResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateDownloadURLResponse{}, runtime.NewResponseError(resp) + } + return client.generateDownloadURLHandleResponse(resp) +} + +// generateDownloadURLCreateRequest creates the GenerateDownloadURL request. +func (client *FirmwareClient) generateDownloadURLCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateDownloadURLOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateDownloadUrl" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateDownloadURLHandleResponse handles the GenerateDownloadURL response. +func (client *FirmwareClient) generateDownloadURLHandleResponse(resp *http.Response) (FirmwareClientGenerateDownloadURLResponse, error) { + result := FirmwareClientGenerateDownloadURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.URLToken); err != nil { + return FirmwareClientGenerateDownloadURLResponse{}, err + } + return result, nil +} + +// GenerateFilesystemDownloadURL - The operation to a url for tar file download. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateFilesystemDownloadURLOptions contains the optional parameters for the FirmwareClient.GenerateFilesystemDownloadURL +// method. +func (client *FirmwareClient) GenerateFilesystemDownloadURL(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateFilesystemDownloadURLOptions) (FirmwareClientGenerateFilesystemDownloadURLResponse, error) { + req, err := client.generateFilesystemDownloadURLCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateFilesystemDownloadURLResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateFilesystemDownloadURLResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateFilesystemDownloadURLResponse{}, runtime.NewResponseError(resp) + } + return client.generateFilesystemDownloadURLHandleResponse(resp) +} + +// generateFilesystemDownloadURLCreateRequest creates the GenerateFilesystemDownloadURL request. +func (client *FirmwareClient) generateFilesystemDownloadURLCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateFilesystemDownloadURLOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateFilesystemDownloadUrl" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateFilesystemDownloadURLHandleResponse handles the GenerateFilesystemDownloadURL response. +func (client *FirmwareClient) generateFilesystemDownloadURLHandleResponse(resp *http.Response) (FirmwareClientGenerateFilesystemDownloadURLResponse, error) { + result := FirmwareClientGenerateFilesystemDownloadURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.URLToken); err != nil { + return FirmwareClientGenerateFilesystemDownloadURLResponse{}, err + } + return result, nil +} + +// GenerateSummary - The operation to get a scan summary. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGenerateSummaryOptions contains the optional parameters for the FirmwareClient.GenerateSummary +// method. +func (client *FirmwareClient) GenerateSummary(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateSummaryOptions) (FirmwareClientGenerateSummaryResponse, error) { + req, err := client.generateSummaryCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGenerateSummaryResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGenerateSummaryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGenerateSummaryResponse{}, runtime.NewResponseError(resp) + } + return client.generateSummaryHandleResponse(resp) +} + +// generateSummaryCreateRequest creates the GenerateSummary request. +func (client *FirmwareClient) generateSummaryCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGenerateSummaryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateSummary" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateSummaryHandleResponse handles the GenerateSummary response. +func (client *FirmwareClient) generateSummaryHandleResponse(resp *http.Response) (FirmwareClientGenerateSummaryResponse, error) { + result := FirmwareClientGenerateSummaryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FirmwareSummary); err != nil { + return FirmwareClientGenerateSummaryResponse{}, err + } + return result, nil +} + +// Get - Get firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientGetOptions contains the optional parameters for the FirmwareClient.Get method. +func (client *FirmwareClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGetOptions) (FirmwareClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + if err != nil { + return FirmwareClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *FirmwareClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}" + 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)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FirmwareClient) getHandleResponse(resp *http.Response) (FirmwareClientGetResponse, error) { + result := FirmwareClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Firmware); err != nil { + return FirmwareClientGetResponse{}, err + } + return result, nil +} + +// NewListByWorkspacePager - Lists all of firmwares inside a workspace. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - options - FirmwareClientListByWorkspaceOptions contains the optional parameters for the FirmwareClient.NewListByWorkspacePager +// method. +func (client *FirmwareClient) NewListByWorkspacePager(resourceGroupName string, workspaceName string, options *FirmwareClientListByWorkspaceOptions) *runtime.Pager[FirmwareClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListByWorkspaceResponse]{ + More: func(page FirmwareClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListByWorkspaceResponse) (FirmwareClientListByWorkspaceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListByWorkspaceResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListByWorkspaceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListByWorkspaceResponse{}, runtime.NewResponseError(resp) + } + return client.listByWorkspaceHandleResponse(resp) + }, + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *FirmwareClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *FirmwareClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *FirmwareClient) listByWorkspaceHandleResponse(resp *http.Response) (FirmwareClientListByWorkspaceResponse, error) { + result := FirmwareClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FirmwareList); err != nil { + return FirmwareClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// NewListGenerateBinaryHardeningListPager - The operation to list all binary hardening result for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGenerateBinaryHardeningListOptions contains the optional parameters for the FirmwareClient.NewListGenerateBinaryHardeningListPager +// method. +func (client *FirmwareClient) NewListGenerateBinaryHardeningListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateBinaryHardeningListOptions) *runtime.Pager[FirmwareClientListGenerateBinaryHardeningListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGenerateBinaryHardeningListResponse]{ + More: func(page FirmwareClientListGenerateBinaryHardeningListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGenerateBinaryHardeningListResponse) (FirmwareClientListGenerateBinaryHardeningListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGenerateBinaryHardeningListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGenerateBinaryHardeningListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGenerateBinaryHardeningListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGenerateBinaryHardeningListResponse{}, runtime.NewResponseError(resp) + } + return client.listGenerateBinaryHardeningListHandleResponse(resp) + }, + }) +} + +// listGenerateBinaryHardeningListCreateRequest creates the ListGenerateBinaryHardeningList request. +func (client *FirmwareClient) listGenerateBinaryHardeningListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateBinaryHardeningListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateBinaryHardeningList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGenerateBinaryHardeningListHandleResponse handles the ListGenerateBinaryHardeningList response. +func (client *FirmwareClient) listGenerateBinaryHardeningListHandleResponse(resp *http.Response) (FirmwareClientListGenerateBinaryHardeningListResponse, error) { + result := FirmwareClientListGenerateBinaryHardeningListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BinaryHardeningList); err != nil { + return FirmwareClientListGenerateBinaryHardeningListResponse{}, err + } + return result, nil +} + +// NewListGenerateComponentListPager - The operation to list all components result for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGenerateComponentListOptions contains the optional parameters for the FirmwareClient.NewListGenerateComponentListPager +// method. +func (client *FirmwareClient) NewListGenerateComponentListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateComponentListOptions) *runtime.Pager[FirmwareClientListGenerateComponentListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGenerateComponentListResponse]{ + More: func(page FirmwareClientListGenerateComponentListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGenerateComponentListResponse) (FirmwareClientListGenerateComponentListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGenerateComponentListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGenerateComponentListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGenerateComponentListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGenerateComponentListResponse{}, runtime.NewResponseError(resp) + } + return client.listGenerateComponentListHandleResponse(resp) + }, + }) +} + +// listGenerateComponentListCreateRequest creates the ListGenerateComponentList request. +func (client *FirmwareClient) listGenerateComponentListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateComponentListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateComponentList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGenerateComponentListHandleResponse handles the ListGenerateComponentList response. +func (client *FirmwareClient) listGenerateComponentListHandleResponse(resp *http.Response) (FirmwareClientListGenerateComponentListResponse, error) { + result := FirmwareClientListGenerateComponentListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ComponentList); err != nil { + return FirmwareClientListGenerateComponentListResponse{}, err + } + return result, nil +} + +// NewListGenerateCryptoCertificateListPager - The operation to list all crypto certificates for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGenerateCryptoCertificateListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCryptoCertificateListPager +// method. +func (client *FirmwareClient) NewListGenerateCryptoCertificateListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCryptoCertificateListOptions) *runtime.Pager[FirmwareClientListGenerateCryptoCertificateListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGenerateCryptoCertificateListResponse]{ + More: func(page FirmwareClientListGenerateCryptoCertificateListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGenerateCryptoCertificateListResponse) (FirmwareClientListGenerateCryptoCertificateListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGenerateCryptoCertificateListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGenerateCryptoCertificateListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGenerateCryptoCertificateListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGenerateCryptoCertificateListResponse{}, runtime.NewResponseError(resp) + } + return client.listGenerateCryptoCertificateListHandleResponse(resp) + }, + }) +} + +// listGenerateCryptoCertificateListCreateRequest creates the ListGenerateCryptoCertificateList request. +func (client *FirmwareClient) listGenerateCryptoCertificateListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCryptoCertificateListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCryptoCertificateList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGenerateCryptoCertificateListHandleResponse handles the ListGenerateCryptoCertificateList response. +func (client *FirmwareClient) listGenerateCryptoCertificateListHandleResponse(resp *http.Response) (FirmwareClientListGenerateCryptoCertificateListResponse, error) { + result := FirmwareClientListGenerateCryptoCertificateListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CryptoCertificateList); err != nil { + return FirmwareClientListGenerateCryptoCertificateListResponse{}, err + } + return result, nil +} + +// NewListGenerateCryptoKeyListPager - The operation to list all crypto keys for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGenerateCryptoKeyListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCryptoKeyListPager +// method. +func (client *FirmwareClient) NewListGenerateCryptoKeyListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCryptoKeyListOptions) *runtime.Pager[FirmwareClientListGenerateCryptoKeyListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGenerateCryptoKeyListResponse]{ + More: func(page FirmwareClientListGenerateCryptoKeyListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGenerateCryptoKeyListResponse) (FirmwareClientListGenerateCryptoKeyListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGenerateCryptoKeyListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGenerateCryptoKeyListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGenerateCryptoKeyListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGenerateCryptoKeyListResponse{}, runtime.NewResponseError(resp) + } + return client.listGenerateCryptoKeyListHandleResponse(resp) + }, + }) +} + +// listGenerateCryptoKeyListCreateRequest creates the ListGenerateCryptoKeyList request. +func (client *FirmwareClient) listGenerateCryptoKeyListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCryptoKeyListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCryptoKeyList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGenerateCryptoKeyListHandleResponse handles the ListGenerateCryptoKeyList response. +func (client *FirmwareClient) listGenerateCryptoKeyListHandleResponse(resp *http.Response) (FirmwareClientListGenerateCryptoKeyListResponse, error) { + result := FirmwareClientListGenerateCryptoKeyListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CryptoKeyList); err != nil { + return FirmwareClientListGenerateCryptoKeyListResponse{}, err + } + return result, nil +} + +// NewListGenerateCveListPager - The operation to list all cve results for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGenerateCveListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCveListPager +// method. +func (client *FirmwareClient) NewListGenerateCveListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCveListOptions) *runtime.Pager[FirmwareClientListGenerateCveListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGenerateCveListResponse]{ + More: func(page FirmwareClientListGenerateCveListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGenerateCveListResponse) (FirmwareClientListGenerateCveListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGenerateCveListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGenerateCveListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGenerateCveListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGenerateCveListResponse{}, runtime.NewResponseError(resp) + } + return client.listGenerateCveListHandleResponse(resp) + }, + }) +} + +// listGenerateCveListCreateRequest creates the ListGenerateCveList request. +func (client *FirmwareClient) listGenerateCveListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGenerateCveListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generateCveList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGenerateCveListHandleResponse handles the ListGenerateCveList response. +func (client *FirmwareClient) listGenerateCveListHandleResponse(resp *http.Response) (FirmwareClientListGenerateCveListResponse, error) { + result := FirmwareClientListGenerateCveListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CveList); err != nil { + return FirmwareClientListGenerateCveListResponse{}, err + } + return result, nil +} + +// NewListGeneratePasswordHashListPager - The operation to list all password hashes for a firmware. +// +// Generated from API version 2023-02-08-preview +// - 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 - FirmwareClientListGeneratePasswordHashListOptions contains the optional parameters for the FirmwareClient.NewListGeneratePasswordHashListPager +// method. +func (client *FirmwareClient) NewListGeneratePasswordHashListPager(resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGeneratePasswordHashListOptions) *runtime.Pager[FirmwareClientListGeneratePasswordHashListResponse] { + return runtime.NewPager(runtime.PagingHandler[FirmwareClientListGeneratePasswordHashListResponse]{ + More: func(page FirmwareClientListGeneratePasswordHashListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FirmwareClientListGeneratePasswordHashListResponse) (FirmwareClientListGeneratePasswordHashListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listGeneratePasswordHashListCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FirmwareClientListGeneratePasswordHashListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientListGeneratePasswordHashListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FirmwareClientListGeneratePasswordHashListResponse{}, runtime.NewResponseError(resp) + } + return client.listGeneratePasswordHashListHandleResponse(resp) + }, + }) +} + +// listGeneratePasswordHashListCreateRequest creates the ListGeneratePasswordHashList request. +func (client *FirmwareClient) listGeneratePasswordHashListCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, options *FirmwareClientListGeneratePasswordHashListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}/generatePasswordHashList" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGeneratePasswordHashListHandleResponse handles the ListGeneratePasswordHashList response. +func (client *FirmwareClient) listGeneratePasswordHashListHandleResponse(resp *http.Response) (FirmwareClientListGeneratePasswordHashListResponse, error) { + result := FirmwareClientListGeneratePasswordHashListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PasswordHashList); err != nil { + return FirmwareClientListGeneratePasswordHashListResponse{}, err + } + return result, nil +} + +// Update - The operation to update firmware. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - 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. +// - firmware - Details of the firmware being created or updated. +// - options - FirmwareClientUpdateOptions contains the optional parameters for the FirmwareClient.Update method. +func (client *FirmwareClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, firmware FirmwareUpdateDefinition, options *FirmwareClientUpdateOptions) (FirmwareClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, firmwareID, firmware, options) + if err != nil { + return FirmwareClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FirmwareClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return FirmwareClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *FirmwareClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, firmwareID string, firmware FirmwareUpdateDefinition, options *FirmwareClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/firmwares/{firmwareId}" + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, firmware) +} + +// updateHandleResponse handles the Update response. +func (client *FirmwareClient) updateHandleResponse(resp *http.Response) (FirmwareClientUpdateResponse, error) { + result := FirmwareClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Firmware); err != nil { + return FirmwareClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client_example_test.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client_example_test.go new file mode 100644 index 000000000000..4e7d8f99c9a6 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/firmware_client_example_test.go @@ -0,0 +1,1488 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListByWorkspace_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListByWorkspacePager_firmwareListByWorkspaceMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListByWorkspacePager("rgworkspaces-firmwares", "A7", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.FirmwareList = armiotfirmwaredefense.FirmwareList{ + // Value: []*armiotfirmwaredefense.Firmware{ + // { + // Name: to.Ptr("brmvnojpmxsgckdviynhxhftvcvbw"), + // Type: to.Ptr("vlxhdbrphhnttmxvawwwewza"), + // ID: to.Ptr("koexkheccwpzwqob"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // CreatedBy: to.Ptr("aylilpicryidesowemwnl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // LastModifiedBy: to.Ptr("bgtifu"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Properties: &armiotfirmwaredefense.FirmwareProperties{ + // Description: to.Ptr("uz"), + // FileName: to.Ptr("wresexxulcdsdd"), + // FileSize: to.Ptr[int64](17), + // Model: to.Ptr("f"), + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // Status: to.Ptr(armiotfirmwaredefense.StatusPending), + // StatusMessages: []any{ + // map[string]any{ + // "message": "ulvhmhokezathzzauiitu", + // }}, + // Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + // Version: to.Ptr("s"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListByWorkspace_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListByWorkspacePager_firmwareListByWorkspaceMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListByWorkspacePager("rgworkspaces-firmwares", "A7", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.FirmwareList = armiotfirmwaredefense.FirmwareList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Create_MaximumSet_Gen.json +func ExampleFirmwareClient_Create_firmwareCreateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Create(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", armiotfirmwaredefense.Firmware{ + Properties: &armiotfirmwaredefense.FirmwareProperties{ + Description: to.Ptr("uz"), + FileName: to.Ptr("wresexxulcdsdd"), + FileSize: to.Ptr[int64](17), + Model: to.Ptr("f"), + Status: to.Ptr(armiotfirmwaredefense.StatusPending), + StatusMessages: []any{ + map[string]any{ + "message": "ulvhmhokezathzzauiitu", + }}, + Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + Version: to.Ptr("s"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // Name: to.Ptr("brmvnojpmxsgckdviynhxhftvcvbw"), + // Type: to.Ptr("vlxhdbrphhnttmxvawwwewza"), + // ID: to.Ptr("koexkheccwpzwqob"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // CreatedBy: to.Ptr("aylilpicryidesowemwnl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // LastModifiedBy: to.Ptr("bgtifu"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Properties: &armiotfirmwaredefense.FirmwareProperties{ + // Description: to.Ptr("uz"), + // FileName: to.Ptr("wresexxulcdsdd"), + // FileSize: to.Ptr[int64](17), + // Model: to.Ptr("f"), + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // Status: to.Ptr(armiotfirmwaredefense.StatusPending), + // StatusMessages: []any{ + // map[string]any{ + // "message": "ulvhmhokezathzzauiitu", + // }}, + // Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + // Version: to.Ptr("s"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Create_MinimumSet_Gen.json +func ExampleFirmwareClient_Create_firmwareCreateMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Create(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", armiotfirmwaredefense.Firmware{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Update_MaximumSet_Gen.json +func ExampleFirmwareClient_Update_firmwareUpdateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Update(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", armiotfirmwaredefense.FirmwareUpdateDefinition{ + Properties: &armiotfirmwaredefense.FirmwareProperties{ + Description: to.Ptr("uz"), + FileName: to.Ptr("wresexxulcdsdd"), + FileSize: to.Ptr[int64](17), + Model: to.Ptr("f"), + Status: to.Ptr(armiotfirmwaredefense.StatusPending), + StatusMessages: []any{ + map[string]any{ + "message": "ulvhmhokezathzzauiitu", + }}, + Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + Version: to.Ptr("s"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // Name: to.Ptr("brmvnojpmxsgckdviynhxhftvcvbw"), + // Type: to.Ptr("vlxhdbrphhnttmxvawwwewza"), + // ID: to.Ptr("koexkheccwpzwqob"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // CreatedBy: to.Ptr("aylilpicryidesowemwnl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // LastModifiedBy: to.Ptr("bgtifu"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Properties: &armiotfirmwaredefense.FirmwareProperties{ + // Description: to.Ptr("uz"), + // FileName: to.Ptr("wresexxulcdsdd"), + // FileSize: to.Ptr[int64](17), + // Model: to.Ptr("f"), + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // Status: to.Ptr(armiotfirmwaredefense.StatusPending), + // StatusMessages: []any{ + // map[string]any{ + // "message": "ulvhmhokezathzzauiitu", + // }}, + // Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + // Version: to.Ptr("s"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Update_MinimumSet_Gen.json +func ExampleFirmwareClient_Update_firmwareUpdateMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Update(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", armiotfirmwaredefense.FirmwareUpdateDefinition{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Delete_MaximumSet_Gen.json +func ExampleFirmwareClient_Delete_firmwareDeleteMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewFirmwareClient().Delete(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Delete_MinimumSet_Gen.json +func ExampleFirmwareClient_Delete_firmwareDeleteMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewFirmwareClient().Delete(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Get_MaximumSet_Gen.json +func ExampleFirmwareClient_Get_firmwareGetMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Get(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // Name: to.Ptr("brmvnojpmxsgckdviynhxhftvcvbw"), + // Type: to.Ptr("vlxhdbrphhnttmxvawwwewza"), + // ID: to.Ptr("koexkheccwpzwqob"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // CreatedBy: to.Ptr("aylilpicryidesowemwnl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:29.228Z"); return t}()), + // LastModifiedBy: to.Ptr("bgtifu"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Properties: &armiotfirmwaredefense.FirmwareProperties{ + // Description: to.Ptr("uz"), + // FileName: to.Ptr("wresexxulcdsdd"), + // FileSize: to.Ptr[int64](17), + // Model: to.Ptr("f"), + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // Status: to.Ptr(armiotfirmwaredefense.StatusPending), + // StatusMessages: []any{ + // map[string]any{ + // "message": "ulvhmhokezathzzauiitu", + // }}, + // Vendor: to.Ptr("vycmdhgtmepcptyoubztiuudpkcpd"), + // Version: to.Ptr("s"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_Get_MinimumSet_Gen.json +func ExampleFirmwareClient_Get_firmwareGetMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().Get(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Firmware = armiotfirmwaredefense.Firmware{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateDownloadUrl_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateDownloadURL_firmwareGenerateDownloadUrlMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateDownloadURL(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // UploadURL: to.Ptr("https://i/am/a/sas/token/too"), + // URL: to.Ptr("https://i/am/a/sas/token"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateDownloadUrl_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateDownloadURL_firmwareGenerateDownloadUrlMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateDownloadURL(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateFilesystemDownloadUrl_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateFilesystemDownloadURL_firmwareGenerateFilesystemDownloadUrlMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateFilesystemDownloadURL(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // UploadURL: to.Ptr("https://i/am/a/sas/token/too"), + // URL: to.Ptr("https://i/am/a/sas/token"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateFilesystemDownloadUrl_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateFilesystemDownloadURL_firmwareGenerateFilesystemDownloadUrlMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateFilesystemDownloadURL(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateSummary_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateSummary_firmwareGenerateSummaryMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirmwareSummary = armiotfirmwaredefense.FirmwareSummary{ + // AnalysisTimeSeconds: to.Ptr[int64](14), + // BinaryCount: to.Ptr[int64](6), + // ComponentCount: to.Ptr[int64](1), + // ExtractedFileCount: to.Ptr[int64](17), + // ExtractedSize: to.Ptr[int64](23), + // FileSize: to.Ptr[int64](18), + // RootFileSystems: to.Ptr[int64](9), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateSummary_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateSummary_firmwareGenerateSummaryMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FirmwareSummary = armiotfirmwaredefense.FirmwareSummary{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateComponentList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateComponentListPager_firmwareListGenerateComponentListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateComponentListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ComponentList = armiotfirmwaredefense.ComponentList{ + // Value: []*armiotfirmwaredefense.Component{ + // { + // ComponentID: to.Ptr("dwtwgmbjtftea"), + // ComponentName: to.Ptr("wbjvfrmhmumeahdhkla"), + // IsUpdateAvailable: to.Ptr(armiotfirmwaredefense.IsUpdateAvailableTrue), + // License: to.Ptr("tirj"), + // Paths: []*string{ + // to.Ptr("bjxczktgyhpatxkgwomhgfsw")}, + // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:30.304Z"); return t}()), + // Version: to.Ptr("dmokuviyznjbdkfxbmvhlnglfnf"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateComponentList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateComponentListPager_firmwareListGenerateComponentListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateComponentListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ComponentList = armiotfirmwaredefense.ComponentList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateComponentDetails_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateComponentDetails_firmwareGenerateComponentDetailsMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateComponentDetails(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Component = armiotfirmwaredefense.Component{ + // ComponentID: to.Ptr("dwtwgmbjtftea"), + // ComponentName: to.Ptr("wbjvfrmhmumeahdhkla"), + // IsUpdateAvailable: to.Ptr(armiotfirmwaredefense.IsUpdateAvailableTrue), + // License: to.Ptr("tirj"), + // Paths: []*string{ + // to.Ptr("bjxczktgyhpatxkgwomhgfsw")}, + // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:30.304Z"); return t}()), + // Version: to.Ptr("dmokuviyznjbdkfxbmvhlnglfnf"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateComponentDetails_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateComponentDetails_firmwareGenerateComponentDetailsMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateComponentDetails(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Component = armiotfirmwaredefense.Component{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateBinaryHardeningList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateBinaryHardeningListPager_firmwareListGenerateBinaryHardeningListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateBinaryHardeningListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BinaryHardeningList = armiotfirmwaredefense.BinaryHardeningList{ + // Value: []*armiotfirmwaredefense.BinaryHardening{ + // { + // Path: to.Ptr("ewqypeaihlnqdeesblp"), + // Architecture: to.Ptr("rfqnzhnwitn"), + // BinaryHardeningID: to.Ptr("paobczlmlkfeozykeeq"), + // Class: to.Ptr("szvunaemnqnwqmfdx"), + // Features: &armiotfirmwaredefense.BinaryHardeningFeatures{ + // Canary: to.Ptr(armiotfirmwaredefense.CanaryFlagTrue), + // Nx: to.Ptr(armiotfirmwaredefense.NxFlagTrue), + // Pie: to.Ptr(armiotfirmwaredefense.PieFlagTrue), + // Relro: to.Ptr(armiotfirmwaredefense.RelroFlagTrue), + // Stripped: to.Ptr(armiotfirmwaredefense.StrippedFlagTrue), + // }, + // Rpath: to.Ptr("jigblxjxxqiskihigkmpqgrygxxx"), + // Runpath: to.Ptr("aecstzybleqdwwhavfcywyo"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateBinaryHardeningList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateBinaryHardeningListPager_firmwareListGenerateBinaryHardeningListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateBinaryHardeningListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BinaryHardeningList = armiotfirmwaredefense.BinaryHardeningList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateBinaryHardeningSummary_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateBinaryHardeningSummary_firmwareGenerateBinaryHardeningSummaryMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateBinaryHardeningSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BinaryHardeningSummary = armiotfirmwaredefense.BinaryHardeningSummary{ + // Canary: to.Ptr[int32](28), + // Nx: to.Ptr[int32](28), + // Pie: to.Ptr[int32](19), + // Relro: to.Ptr[int32](28), + // Stripped: to.Ptr[int32](17), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateBinaryHardeningSummary_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateBinaryHardeningSummary_firmwareGenerateBinaryHardeningSummaryMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateBinaryHardeningSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BinaryHardeningSummary = armiotfirmwaredefense.BinaryHardeningSummary{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateBinaryHardeningDetails_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateBinaryHardeningDetails_firmwareGenerateBinaryHardeningDetailsMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateBinaryHardeningDetails(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BinaryHardening = armiotfirmwaredefense.BinaryHardening{ + // Path: to.Ptr("ewqypeaihlnqdeesblp"), + // Architecture: to.Ptr("rfqnzhnwitn"), + // BinaryHardeningID: to.Ptr("paobczlmlkfeozykeeq"), + // Class: to.Ptr("szvunaemnqnwqmfdx"), + // Features: &armiotfirmwaredefense.BinaryHardeningFeatures{ + // Canary: to.Ptr(armiotfirmwaredefense.CanaryFlagTrue), + // Nx: to.Ptr(armiotfirmwaredefense.NxFlagTrue), + // Pie: to.Ptr(armiotfirmwaredefense.PieFlagTrue), + // Relro: to.Ptr(armiotfirmwaredefense.RelroFlagTrue), + // Stripped: to.Ptr(armiotfirmwaredefense.StrippedFlagTrue), + // }, + // Rpath: to.Ptr("jigblxjxxqiskihigkmpqgrygxxx"), + // Runpath: to.Ptr("aecstzybleqdwwhavfcywyo"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateBinaryHardeningDetails_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateBinaryHardeningDetails_firmwareGenerateBinaryHardeningDetailsMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateBinaryHardeningDetails(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BinaryHardening = armiotfirmwaredefense.BinaryHardening{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGeneratePasswordHashList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGeneratePasswordHashListPager_firmwareListGeneratePasswordHashListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGeneratePasswordHashListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PasswordHashList = armiotfirmwaredefense.PasswordHashList{ + // Value: []*armiotfirmwaredefense.PasswordHash{ + // { + // Algorithm: to.Ptr("mzvaikhxwjbzddplm"), + // Context: to.Ptr("gjeeqjzcrnbxiojt"), + // FilePath: to.Ptr("xxtrysuheflpailcqzqbvytnsi"), + // Hash: to.Ptr("ntksbuckwsaxdzlstqwenms"), + // PasswordHashID: to.Ptr("twelvrhxk"), + // Salt: to.Ptr("pdlihxaabeaxllsfdthctdcmltyhja"), + // Username: to.Ptr("qvfpcvewrzdosvl"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGeneratePasswordHashList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGeneratePasswordHashListPager_firmwareListGeneratePasswordHashListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGeneratePasswordHashListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PasswordHashList = armiotfirmwaredefense.PasswordHashList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCveList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCveListPager_firmwareListGenerateCveListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCveListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CveList = armiotfirmwaredefense.CveList{ + // Value: []*armiotfirmwaredefense.Cve{ + // { + // Name: to.Ptr("x"), + // Description: to.Ptr("jr"), + // Component: map[string]any{ + // }, + // CveID: to.Ptr("bcmdkqlpeohuweqapzghpxxigubbnv"), + // CvssScore: to.Ptr("kc"), + // CvssV2Score: to.Ptr("qdzatwwrfqs"), + // CvssV3Score: to.Ptr("hltdeqtpizrlxquimvbahazbluzy"), + // CvssVersion: to.Ptr("wlacx"), + // Links: []*armiotfirmwaredefense.CveLink{ + // { + // Href: to.Ptr("dioeprjnkzyk"), + // Label: to.Ptr("oxeatanlztnthd"), + // }}, + // PublishDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:31.081Z"); return t}()), + // Severity: to.Ptr("vwsqmwqxsdvszzdsfhtjep"), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T06:40:31.081Z"); return t}()), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCveList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCveListPager_firmwareListGenerateCveListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCveListPager("rgworkspaces-firmwares", "A7", "umrkdttp", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CveList = armiotfirmwaredefense.CveList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCveSummary_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateCveSummary_firmwareGenerateCveSummaryMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCveSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CveSummary = armiotfirmwaredefense.CveSummary{ + // Critical: to.Ptr[int64](29), + // High: to.Ptr[int64](10), + // Low: to.Ptr[int64](27), + // Medium: to.Ptr[int64](18), + // Undefined: to.Ptr[int64](22), + // Unknown: to.Ptr[int64](2), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCveSummary_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateCveSummary_firmwareGenerateCveSummaryMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCveSummary(ctx, "rgworkspaces-firmwares", "A7", "umrkdttp", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CveSummary = armiotfirmwaredefense.CveSummary{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCryptoCertificateSummary_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateCryptoCertificateSummary_firmwareGenerateCryptoCertificateSummaryMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCryptoCertificateSummary(ctx, "FirmwareAnalysisRG", "default", "DECAFBAD-0000-0000-0000-BADBADBADBAD", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CryptoCertificateSummary = armiotfirmwaredefense.CryptoCertificateSummary{ + // Expired: to.Ptr[int64](3), + // ExpiringSoon: to.Ptr[int64](1), + // PairedKeys: to.Ptr[int64](2), + // SelfSigned: to.Ptr[int64](3), + // ShortKeySize: to.Ptr[int64](1), + // TotalCertificates: to.Ptr[int64](5), + // WeakSignature: to.Ptr[int64](1), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCryptoCertificateSummary_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateCryptoCertificateSummary_firmwareGenerateCryptoCertificateSummaryMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCryptoCertificateSummary(ctx, "rgworkspaces-firmwares", "j5QE_", "wujtpcgypfpqseyrsebolarkspy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CryptoCertificateSummary = armiotfirmwaredefense.CryptoCertificateSummary{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCryptoKeySummary_MaximumSet_Gen.json +func ExampleFirmwareClient_GenerateCryptoKeySummary_firmwareGenerateCryptoKeySummaryMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCryptoKeySummary(ctx, "FirmwareAnalysisRG", "default", "DECAFBAD-0000-0000-0000-BADBADBADBAD", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CryptoKeySummary = armiotfirmwaredefense.CryptoKeySummary{ + // PairedKeys: to.Ptr[int64](3), + // PrivateKeys: to.Ptr[int64](3), + // PublicKeys: to.Ptr[int64](3), + // ShortKeySize: to.Ptr[int64](2), + // TotalKeys: to.Ptr[int64](6), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_GenerateCryptoKeySummary_MinimumSet_Gen.json +func ExampleFirmwareClient_GenerateCryptoKeySummary_firmwareGenerateCryptoKeySummaryMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirmwareClient().GenerateCryptoKeySummary(ctx, "rgworkspaces-firmwares", "j5QE_", "wujtpcgypfpqseyrsebolarkspy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CryptoKeySummary = armiotfirmwaredefense.CryptoKeySummary{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCryptoCertificateList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCryptoCertificateListPager_firmwareListGenerateCryptoCertificateListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCryptoCertificateListPager("FirmwareAnalysisRG", "default", "DECAFBAD-0000-0000-0000-BADBADBADBAD", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CryptoCertificateList = armiotfirmwaredefense.CryptoCertificateList{ + // Value: []*armiotfirmwaredefense.CryptoCertificate{ + // { + // Name: to.Ptr("VeriSign Class 3"), + // CryptoCertID: to.Ptr("fafcad44-1770-41f3-998e-875fa688c143"), + // Encoding: to.Ptr("PEM"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2012-02-12T20:50:16.753Z"); return t}()), + // FilePaths: []*string{ + // to.Ptr("this/is/a/path"), + // to.Ptr("/this/is/another/path")}, + // Fingerprint: to.Ptr("eb:04:cf:5e:b1:f3:9a:fa:76:2f:2b:b1:20:f2:96:cb:a5:20:c1:b9:7d:b1:58:95:65:b8:1c:b9:a1:7b:72:44"), + // IsExpired: to.Ptr(armiotfirmwaredefense.IsExpiredTrue), + // IsSelfSigned: to.Ptr(armiotfirmwaredefense.IsSelfSignedFalse), + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeTrue), + // IsWeakSignature: to.Ptr(armiotfirmwaredefense.IsWeakSignatureTrue), + // IssuedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2010-02-12T20:50:16.753Z"); return t}()), + // Issuer: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // KeyAlgorithm: to.Ptr("RSA Encryption"), + // KeySize: to.Ptr[int64](1024), + // PairedKey: &armiotfirmwaredefense.PairedKey{ + // Type: to.Ptr("Private Key"), + // AdditionalProperties: map[string]any{ + // "displayName": "keyfilename.cer", + // }, + // ID: to.Ptr("fafcad44-1770-41f3-998e-875fa688c143"), + // }, + // Role: to.Ptr("Root CA"), + // SerialNumber: to.Ptr("206684696279472310254277870180966723415"), + // SignatureAlgorithm: to.Ptr("MD5 with RSA Encryption"), + // Subject: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // Usage: []*string{ + // to.Ptr("Crypt"), + // to.Ptr("sign"), + // to.Ptr("auth")}, + // }, + // { + // Name: to.Ptr("VeriSign Class 2"), + // CryptoCertID: to.Ptr("dfc4a7e4-2037-482a-bdf8-81289335337e"), + // Encoding: to.Ptr("PEM"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "1999-12-31T23:59:59.999"); return t}()), + // FilePaths: []*string{ + // to.Ptr("this/is/a/path"), + // to.Ptr("/this/is/another/path")}, + // Fingerprint: to.Ptr("eb:04:cf:5e:b1:f3:9a:fa:76:2f:2b:b1:20:f2:96:cb:a5:20:c1:b9:7d:b1:58:95:65:b8:1c:b9:a1:7b:72:44"), + // IsExpired: to.Ptr(armiotfirmwaredefense.IsExpiredTrue), + // IsSelfSigned: to.Ptr(armiotfirmwaredefense.IsSelfSignedFalse), + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // IsWeakSignature: to.Ptr(armiotfirmwaredefense.IsWeakSignatureFalse), + // IssuedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "1970-01-01T00:00:00.000Z"); return t}()), + // Issuer: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // KeyAlgorithm: to.Ptr("RSA Encryption"), + // KeySize: to.Ptr[int64](2048), + // PairedKey: &armiotfirmwaredefense.PairedKey{ + // Type: to.Ptr("Private Key"), + // ID: to.Ptr("fafcad44-1770-41f3-998e-875fa688c143"), + // }, + // Role: to.Ptr("Intermediate CA"), + // SerialNumber: to.Ptr("206684696279472310254277870180966723415"), + // SignatureAlgorithm: to.Ptr("SHA-1 with RSA Encryption"), + // Subject: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // Usage: []*string{ + // to.Ptr("Crypt"), + // to.Ptr("sign"), + // to.Ptr("auth")}, + // }, + // { + // Name: to.Ptr("JillianSign Class 1"), + // CryptoCertID: to.Ptr("55d8329d-6f4b-4a36-a6a7-53f2ddf187b5"), + // Encoding: to.Ptr("PEM"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-16T20:50:16.753Z"); return t}()), + // FilePaths: []*string{ + // to.Ptr("this/is/a/path/made/by/Jillian"), + // to.Ptr("/this/is/another/path")}, + // Fingerprint: to.Ptr("eb:04:cf:5e:b1:f3:9a:fa:76:2f:2b:b1:20:f2:96:cb:a5:20:c1:b9:7d:b1:58:95:65:b8:1c:b9:a1:7b:72:44"), + // IsExpired: to.Ptr(armiotfirmwaredefense.IsExpiredTrue), + // IsSelfSigned: to.Ptr(armiotfirmwaredefense.IsSelfSignedTrue), + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // IsWeakSignature: to.Ptr(armiotfirmwaredefense.IsWeakSignatureFalse), + // IssuedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-16T20:50:16.753Z"); return t}()), + // Issuer: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // KeyAlgorithm: to.Ptr("RSA Encryption"), + // KeySize: to.Ptr[int64](2048), + // Role: to.Ptr("Standard"), + // SerialNumber: to.Ptr("206684696279472310254277870180966723415"), + // SignatureAlgorithm: to.Ptr("SHA-1 with RSA Encryption"), + // Subject: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("JillianSign Class 1"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Jilliansign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 2007 Jilliansign inc."), + // State: to.Ptr("MA"), + // }, + // Usage: []*string{ + // to.Ptr("Crypt"), + // to.Ptr("sign"), + // to.Ptr("auth")}, + // }, + // { + // Name: to.Ptr("MikeSign Class 5"), + // CryptoCertID: to.Ptr("c9c1466a-bef5-4883-872e-bc59375f5d89"), + // Encoding: to.Ptr("PEM"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-16T20:50:16.753Z"); return t}()), + // FilePaths: []*string{ + // to.Ptr("this/is/a/path/by/Mike/but/isExpired/and/could/get/pretty/long"), + // to.Ptr("/this/is/another/path")}, + // Fingerprint: to.Ptr("eb:04:cf:5e:b1:f3:9a:fa:76:2f:2b:b1:20:f2:96:cb:a5:20:c1:b9:7d:b1:58:95:65:b8:1c:b9:a1:7b:72:44"), + // IsExpired: to.Ptr(armiotfirmwaredefense.IsExpiredFalse), + // IsSelfSigned: to.Ptr(armiotfirmwaredefense.IsSelfSignedTrue), + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // IsWeakSignature: to.Ptr(armiotfirmwaredefense.IsWeakSignatureFalse), + // IssuedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-16T20:50:16.753Z"); return t}()), + // Issuer: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // KeyAlgorithm: to.Ptr("RSA Encryption"), + // KeySize: to.Ptr[int64](2048), + // Role: to.Ptr("Root CA"), + // SerialNumber: to.Ptr("206684696279472310254277870180966723415"), + // SignatureAlgorithm: to.Ptr("SHA-1 with RSA Encryption"), + // Subject: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("MikeSign Class 5"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Mikesign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 2021 Mikesign inc."), + // State: to.Ptr("MD"), + // }, + // Usage: []*string{ + // to.Ptr("Crypt"), + // to.Ptr("sign"), + // to.Ptr("auth")}, + // }, + // { + // Name: to.Ptr("PeterSign Class 1000"), + // CryptoCertID: to.Ptr("0b580a77-228b-4786-b623-518ec8cdd564"), + // Encoding: to.Ptr("PEM"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-03-16T20:50:16.753Z"); return t}()), + // FilePaths: []*string{ + // to.Ptr("this/is/a/path/for/Peters/puzzlers"), + // to.Ptr("/this/is/another/path")}, + // Fingerprint: to.Ptr("eb:04:cf:5e:b1:f3:9a:fa:76:2f:2b:b1:20:f2:96:cb:a5:20:c1:b9:7d:b1:58:95:65:b8:1c:b9:a1:7b:72:44"), + // IsExpired: to.Ptr(armiotfirmwaredefense.IsExpiredFalse), + // IsSelfSigned: to.Ptr(armiotfirmwaredefense.IsSelfSignedTrue), + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // IsWeakSignature: to.Ptr(armiotfirmwaredefense.IsWeakSignatureFalse), + // IssuedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-16T20:50:16.753Z"); return t}()), + // Issuer: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("VeriSign Class 3"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Verisign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Verisign inc."), + // State: to.Ptr("NY"), + // }, + // KeyAlgorithm: to.Ptr("RSA Encryption"), + // KeySize: to.Ptr[int64](2048), + // Role: to.Ptr("Standard"), + // SerialNumber: to.Ptr("206684696279472310254277870180966723415"), + // SignatureAlgorithm: to.Ptr("SHA-1 with RSA Encryption"), + // Subject: &armiotfirmwaredefense.CryptoCertificateEntity{ + // CommonName: to.Ptr("PeterSign Class 1000"), + // Country: to.Ptr("United States"), + // Organization: to.Ptr("Petersign, Inc."), + // OrganizationalUnit: to.Ptr("(c) 1999 Petersign inc."), + // State: to.Ptr("MD"), + // }, + // Usage: []*string{ + // to.Ptr("Crypt"), + // to.Ptr("sign"), + // to.Ptr("auth")}, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCryptoCertificateList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCryptoCertificateListPager_firmwareListGenerateCryptoCertificateListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCryptoCertificateListPager("rgworkspaces-firmwares", "j5QE_", "wujtpcgypfpqseyrsebolarkspy", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CryptoCertificateList = armiotfirmwaredefense.CryptoCertificateList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCryptoKeyList_MaximumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCryptoKeyListPager_firmwareListGenerateCryptoKeyListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCryptoKeyListPager("FirmwareAnalysisRG", "default", "DECAFBAD-0000-0000-0000-BADBADBADBAD", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CryptoKeyList = armiotfirmwaredefense.CryptoKeyList{ + // Value: []*armiotfirmwaredefense.CryptoKey{ + // { + // CryptoKeyID: to.Ptr("09c97cb7-0963-41ad-b9e2-0be7b10ac1bf"), + // FilePaths: []*string{ + // to.Ptr("this/is/a/file/path"), + // to.Ptr("this/is/another/file/path")}, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // KeyAlgorithm: to.Ptr("ECDSA"), + // KeySize: to.Ptr[int64](256), + // KeyType: to.Ptr("Public"), + // PairedKey: &armiotfirmwaredefense.PairedKey{ + // Type: to.Ptr("Certificate"), + // AdditionalProperties: map[string]any{ + // "displayName": "VeriSign Class 2", + // }, + // ID: to.Ptr("09c97cb7-0963-41ad-b9e2-0be7b10ac1bf"), + // }, + // Usage: []*string{ + // }, + // }, + // { + // CryptoKeyID: to.Ptr("98ff3d6c-bb76-4037-b73e-89b3b47efd71"), + // FilePaths: []*string{ + // to.Ptr("this/is/a/file/path_pub.pem")}, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // KeyAlgorithm: to.Ptr("RSA"), + // KeySize: to.Ptr[int64](2048), + // KeyType: to.Ptr("Public"), + // PairedKey: &armiotfirmwaredefense.PairedKey{ + // Type: to.Ptr("Private Key"), + // ID: to.Ptr("adfe0c4c-7d23-4f4f-a8bb-e65b8f455287"), + // }, + // Usage: []*string{ + // to.Ptr("SSH")}, + // }, + // { + // CryptoKeyID: to.Ptr("1beb6fac-1cfe-431c-9437-ea8cfa9e6aaa"), + // FilePaths: []*string{ + // }, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeTrue), + // KeyAlgorithm: to.Ptr("ECDSA"), + // KeySize: to.Ptr[int64](128), + // KeyType: to.Ptr("Public"), + // Usage: []*string{ + // }, + // }, + // { + // CryptoKeyID: to.Ptr("adfe0c4c-7d23-4f4f-a8bb-e65b8f455287"), + // FilePaths: []*string{ + // to.Ptr("this/is/a/file/path.pem")}, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // KeyAlgorithm: to.Ptr("RSA"), + // KeySize: to.Ptr[int64](2048), + // KeyType: to.Ptr("Private"), + // PairedKey: &armiotfirmwaredefense.PairedKey{ + // Type: to.Ptr("Public Key"), + // ID: to.Ptr("98ff3d6c-bb76-4037-b73e-89b3b47efd71"), + // }, + // Usage: []*string{ + // to.Ptr("SSH")}, + // }, + // { + // CryptoKeyID: to.Ptr("8c8d1003-efb2-4c54-83d6-16dc6a5bbfd5"), + // FilePaths: []*string{ + // }, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeTrue), + // KeyAlgorithm: to.Ptr("RSA"), + // KeySize: to.Ptr[int64](1024), + // KeyType: to.Ptr("Private"), + // Usage: []*string{ + // }, + // }, + // { + // CryptoKeyID: to.Ptr("0b04fc4c-bfbd-491b-b4c8-e93b0b0b28e9"), + // FilePaths: []*string{ + // to.Ptr("this/is/a/file/path"), + // to.Ptr("this/is/another/file/path")}, + // IsShortKeySize: to.Ptr(armiotfirmwaredefense.IsShortKeySizeFalse), + // KeyAlgorithm: to.Ptr("MD5"), + // KeySize: to.Ptr[int64](256), + // KeyType: to.Ptr("Private"), + // Usage: []*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Firmware_ListGenerateCryptoKeyList_MinimumSet_Gen.json +func ExampleFirmwareClient_NewListGenerateCryptoKeyListPager_firmwareListGenerateCryptoKeyListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirmwareClient().NewListGenerateCryptoKeyListPager("rgworkspaces-firmwares", "j5QE_", "wujtpcgypfpqseyrsebolarkspy", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CryptoKeyList = armiotfirmwaredefense.CryptoKeyList{ + // } + } +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.mod b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.mod new file mode 100644 index 000000000000..d4287d58d606 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect +) diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.sum b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.sum new file mode 100644 index 000000000000..21718b486698 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/go.sum @@ -0,0 +1,31 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models.go new file mode 100644 index 000000000000..79a7952cf957 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models.go @@ -0,0 +1,780 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +import "time" + +// BinaryHardening - Binary hardening of a firmware. +type BinaryHardening struct { + // The architecture of the uploaded firmware. + Architecture *string + + // ID for the binary hardening result. + BinaryHardeningID *string + + // class for binary hardening. + Class *string + + // Binary hardening features. + Features *BinaryHardeningFeatures + + // path for binary hardening. + Path *string + + // The rpath of the uploaded firmware. + Rpath *string + + // The runpath of the uploaded firmware. + Runpath *string +} + +// BinaryHardeningFeatures - Binary hardening features. +type BinaryHardeningFeatures struct { + // Canary flag. + Canary *CanaryFlag + + // NX flag. + Nx *NxFlag + + // PIE flag. + Pie *PieFlag + + // RELRO flag. + Relro *RelroFlag + + // Stripped flag. + Stripped *StrippedFlag +} + +// BinaryHardeningList - List result for binary hardening +type BinaryHardeningList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; The list of binary hardening results. + Value []*BinaryHardening +} + +// BinaryHardeningSummary - Binary hardening summary percentages. +type BinaryHardeningSummary struct { + // Canary summary percentage + Canary *int32 + + // NX summary percentage + Nx *int32 + + // PIE summary percentage + Pie *int32 + + // RELRO summary percentage + Relro *int32 + + // Stripped summary percentage + Stripped *int32 + + // Total number of binaries that were analyzed + TotalFiles *int64 +} + +// Component of a firmware. +type Component struct { + // ID for the component. + ComponentID *string + + // Name for the component. + ComponentName *string + + // Flag if new update is available for the component. + IsUpdateAvailable *IsUpdateAvailable + + // License for the component. + License *string + + // Paths of the component. + Paths []*string + + // Release date for the component. + ReleaseDate *time.Time + + // Version for the component. + Version *string +} + +// ComponentList - List result for components +type ComponentList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; The list of components. + Value []*Component +} + +// CryptoCertificate - Crypto certificate properties +type CryptoCertificate struct { + // ID for the certificate. + CryptoCertID *string + + // Encoding used for the certificate. + Encoding *string + + // Expiration date for the certificate. + ExpirationDate *time.Time + + // Fingerprint of the certificate. + Fingerprint *string + + // Indicates if the certificate is expired. + IsExpired *IsExpired + + // Indicates if the certificate was self-signed. + IsSelfSigned *IsSelfSigned + + // Indicates the certificate's key size is considered too small to be secure for the key algorithm. + IsShortKeySize *IsShortKeySize + + // Indicates the signature algorithm used is insecure. + IsWeakSignature *IsWeakSignature + + // Issue date for the certificate. + IssuedDate *time.Time + + // Issuer information of the certificate. + Issuer *CryptoCertificateEntity + + // Key algorithm used in the certificate. + KeyAlgorithm *string + + // Size of the certificate's key in bits + KeySize *int64 + + // Name of the certificate. + Name *string + + // A matching paired private key. + PairedKey *PairedKey + + // Role of the certificate (Root CA, etc) + Role *string + + // Serial number of the certificate. + SerialNumber *string + + // The signature algorithm used in the certificate. + SignatureAlgorithm *string + + // Subject information of the certificate. + Subject *CryptoCertificateEntity + + // List of functions the certificate can fulfill. + Usage []*string + + // READ-ONLY; List of files paths for this certificate + FilePaths []*string +} + +// CryptoCertificateEntity - Information on an entity (distinguished name) in a cryptographic certificate. +type CryptoCertificateEntity struct { + // Common name of the certificate entity. + CommonName *string + + // Country code of the certificate entity. + Country *string + + // Organization of the certificate entity. + Organization *string + + // The organizational unit of the certificate entity. + OrganizationalUnit *string + + // Geographical state or province of the certificate entity. + State *string +} + +// CryptoCertificateList - Crypto certificates list +type CryptoCertificateList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; Crypto certificates list + Value []*CryptoCertificate +} + +// CryptoCertificateSummary - Cryptographic certificate summary values. +type CryptoCertificateSummary struct { + // Total number of expired certificates found. + Expired *int64 + + // Total number of nearly expired certificates found. + ExpiringSoon *int64 + + // Total number of paired private keys found for the certificates. + PairedKeys *int64 + + // Total number of certificates found that are self-signed. + SelfSigned *int64 + + // Total number of certificates found that have an insecure key size for the key algorithm. + ShortKeySize *int64 + + // Total number of certificates found. + TotalCertificates *int64 + + // Total number of certificates found using a weak signature algorithm. + WeakSignature *int64 +} + +// CryptoKey - Crypto key properties +type CryptoKey struct { + // ID for the key. + CryptoKeyID *string + + // Indicates the key size is considered too small to be secure for the algorithm. + IsShortKeySize *IsShortKeySize + + // Key algorithm name. + KeyAlgorithm *string + + // Size of the key in bits. + KeySize *int64 + + // Type of the key (public or private). + KeyType *string + + // A matching paired key or certificate. + PairedKey *PairedKey + + // Functions the key can fulfill. + Usage []*string + + // READ-ONLY; List of files paths for this key. + FilePaths []*string +} + +// CryptoKeyList - Crypto keys list +type CryptoKeyList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; Crypto keys list + Value []*CryptoKey +} + +// CryptoKeySummary - Cryptographic key summary values. +type CryptoKeySummary struct { + // Total number of keys found that have a matching paired key or certificate. + PairedKeys *int64 + + // Total number of private keys found. + PrivateKeys *int64 + + // Total number of (non-certificate) public keys found. + PublicKeys *int64 + + // Total number of keys found that have an insecure key size for the algorithm. + ShortKeySize *int64 + + // Total number of cryptographic keys found. + TotalKeys *int64 +} + +// Cve - Known CVEs of a firmware. +type Cve struct { + // Component of CVE + Component any + + // ID of CVE + CveID *string + + // A single CVSS score to represent the CVE. If a V3 score is specified, then it will use the V3 score. Otherwise if the V2 + // score is specified it will be the V2 score + CvssScore *string + + // Cvss V2 score of CVE + CvssV2Score *string + + // Cvss V3 score of CVE + CvssV3Score *string + + // Cvss version of CVE + CvssVersion *string + + // Description of CVE + Description *string + + // Name of CVE + Name *string + + // Publish date of CVE + PublishDate *time.Time + + // Severity of CVE + Severity *string + + // Updated date of CVE + UpdatedDate *time.Time + + // READ-ONLY; The list of CVE links. + Links []*CveLink +} + +// CveLink - Link for CVE +type CveLink struct { + // Href of CVE link + Href *string + + // Label of CVE link + Label *string +} + +// CveList - List result for CVE +type CveList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; The list of CVE results. + Value []*Cve +} + +// CveSummary - CVE summary values. +type CveSummary struct { + // The total number of critical severity CVEs detected + Critical *int64 + + // The total number of high severity CVEs detected + High *int64 + + // The total number of low severity CVEs detected + Low *int64 + + // The total number of medium severity CVEs detected + Medium *int64 + + // The total number of undefined severity CVEs detected + Undefined *int64 + + // The total number of unknown severity CVEs detected + Unknown *int64 +} + +// Firmware definition +type Firmware struct { + // The properties of a firmware + Properties *FirmwareProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// FirmwareClientCreateOptions contains the optional parameters for the FirmwareClient.Create method. +type FirmwareClientCreateOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientDeleteOptions contains the optional parameters for the FirmwareClient.Delete method. +type FirmwareClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateBinaryHardeningDetailsOptions contains the optional parameters for the FirmwareClient.GenerateBinaryHardeningDetails +// method. +type FirmwareClientGenerateBinaryHardeningDetailsOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateBinaryHardeningSummaryOptions contains the optional parameters for the FirmwareClient.GenerateBinaryHardeningSummary +// method. +type FirmwareClientGenerateBinaryHardeningSummaryOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateComponentDetailsOptions contains the optional parameters for the FirmwareClient.GenerateComponentDetails +// method. +type FirmwareClientGenerateComponentDetailsOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateCryptoCertificateSummaryOptions contains the optional parameters for the FirmwareClient.GenerateCryptoCertificateSummary +// method. +type FirmwareClientGenerateCryptoCertificateSummaryOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateCryptoKeySummaryOptions contains the optional parameters for the FirmwareClient.GenerateCryptoKeySummary +// method. +type FirmwareClientGenerateCryptoKeySummaryOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateCveSummaryOptions contains the optional parameters for the FirmwareClient.GenerateCveSummary method. +type FirmwareClientGenerateCveSummaryOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateDownloadURLOptions contains the optional parameters for the FirmwareClient.GenerateDownloadURL method. +type FirmwareClientGenerateDownloadURLOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateFilesystemDownloadURLOptions contains the optional parameters for the FirmwareClient.GenerateFilesystemDownloadURL +// method. +type FirmwareClientGenerateFilesystemDownloadURLOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGenerateSummaryOptions contains the optional parameters for the FirmwareClient.GenerateSummary method. +type FirmwareClientGenerateSummaryOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientGetOptions contains the optional parameters for the FirmwareClient.Get method. +type FirmwareClientGetOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListByWorkspaceOptions contains the optional parameters for the FirmwareClient.NewListByWorkspacePager method. +type FirmwareClientListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGenerateBinaryHardeningListOptions contains the optional parameters for the FirmwareClient.NewListGenerateBinaryHardeningListPager +// method. +type FirmwareClientListGenerateBinaryHardeningListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGenerateComponentListOptions contains the optional parameters for the FirmwareClient.NewListGenerateComponentListPager +// method. +type FirmwareClientListGenerateComponentListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGenerateCryptoCertificateListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCryptoCertificateListPager +// method. +type FirmwareClientListGenerateCryptoCertificateListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGenerateCryptoKeyListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCryptoKeyListPager +// method. +type FirmwareClientListGenerateCryptoKeyListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGenerateCveListOptions contains the optional parameters for the FirmwareClient.NewListGenerateCveListPager +// method. +type FirmwareClientListGenerateCveListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientListGeneratePasswordHashListOptions contains the optional parameters for the FirmwareClient.NewListGeneratePasswordHashListPager +// method. +type FirmwareClientListGeneratePasswordHashListOptions struct { + // placeholder for future optional parameters +} + +// FirmwareClientUpdateOptions contains the optional parameters for the FirmwareClient.Update method. +type FirmwareClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// FirmwareList - List of firmwares +type FirmwareList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; The list of firmwares. + Value []*Firmware +} + +// FirmwareProperties - Firmware properties. +type FirmwareProperties struct { + // User-specified description of the firmware. + Description *string + + // File name for a firmware that user uploaded. + FileName *string + + // File size of the uploaded firmware image. + FileSize *int64 + + // Firmware model. + Model *string + + // The status of firmware scan. + Status *Status + + // A list of errors or other messages generated during firmware analysis + StatusMessages []any + + // Firmware vendor. + Vendor *string + + // Firmware version. + Version *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// FirmwareSummary - Summary result after scanning the firmware. +type FirmwareSummary struct { + // Time used for analysis + AnalysisTimeSeconds *int64 + + // Binary count + BinaryCount *int64 + + // Components count. + ComponentCount *int64 + + // Extracted file count. + ExtractedFileCount *int64 + + // Total extracted size of the firmware in bytes. + ExtractedSize *int64 + + // Firmware file size in bytes. + FileSize *int64 + + // The number of root file systems found. + RootFileSystems *int64 +} + +// FirmwareUpdateDefinition - Firmware definition +type FirmwareUpdateDefinition struct { + // The editable properties of a firmware + Properties *FirmwareProperties +} + +// GenerateUploadURLRequest - Properties for generating an upload URL +type GenerateUploadURLRequest struct { + // A unique ID for the firmware to be uploaded. + FirmwareID *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PairedKey - Details of a matching paired key or certificate. +type PairedKey struct { + // Additional paired key properties + AdditionalProperties any + + // ID of the paired key or certificate. + ID *string + + // The type indicating whether the paired object is a key or certificate. + Type *string +} + +// PasswordHash - Password hash properties +type PasswordHash struct { + // Algorithm of the password hash + Algorithm *string + + // Context of password hash + Context *string + + // File path of the password hash + FilePath *string + + // Hash of the password + Hash *string + + // ID for password hash + PasswordHashID *string + + // Salt of the password hash + Salt *string + + // User name of password hash + Username *string +} + +// PasswordHashList - Password hashes list +type PasswordHashList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; Password hashes list + Value []*PasswordHash +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// URLToken - Url data for creating or accessing a blob file. +type URLToken struct { + // READ-ONLY; SAS URL for creating or accessing a blob file. + URL *string + + // READ-ONLY; SAS URL for file uploading. Kept for backwards compatibility + UploadURL *string +} + +// Workspace - Firmware analysis workspace. +type Workspace struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Workspace properties. + Properties *WorkspaceProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// WorkspaceList - Return a list of firmware analysis workspaces. +type WorkspaceList struct { + // The uri to fetch the next page of asset. + NextLink *string + + // READ-ONLY; The list of firmware analysis workspaces. + Value []*Workspace +} + +// WorkspaceProperties - Workspace properties. +type WorkspaceProperties struct { + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// WorkspaceUpdateDefinition - Firmware analysis workspace. +type WorkspaceUpdateDefinition struct { + // The editable workspace properties. + Properties *WorkspaceProperties +} + +// WorkspacesClientCreateOptions contains the optional parameters for the WorkspacesClient.Create method. +type WorkspacesClientCreateOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientDeleteOptions contains the optional parameters for the WorkspacesClient.Delete method. +type WorkspacesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientGenerateUploadURLOptions contains the optional parameters for the WorkspacesClient.GenerateUploadURL method. +type WorkspacesClientGenerateUploadURLOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +type WorkspacesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientListByResourceGroupOptions contains the optional parameters for the WorkspacesClient.NewListByResourceGroupPager +// method. +type WorkspacesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientListBySubscriptionOptions contains the optional parameters for the WorkspacesClient.NewListBySubscriptionPager +// method. +type WorkspacesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientUpdateOptions contains the optional parameters for the WorkspacesClient.Update method. +type WorkspacesClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models_serde.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models_serde.go new file mode 100644 index 000000000000..3f4cfbeee5f0 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/models_serde.go @@ -0,0 +1,1520 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type BinaryHardening. +func (b BinaryHardening) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "architecture", b.Architecture) + populate(objectMap, "binaryHardeningId", b.BinaryHardeningID) + populate(objectMap, "class", b.Class) + populate(objectMap, "features", b.Features) + populate(objectMap, "path", b.Path) + populate(objectMap, "rpath", b.Rpath) + populate(objectMap, "runpath", b.Runpath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BinaryHardening. +func (b *BinaryHardening) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "architecture": + err = unpopulate(val, "Architecture", &b.Architecture) + delete(rawMsg, key) + case "binaryHardeningId": + err = unpopulate(val, "BinaryHardeningID", &b.BinaryHardeningID) + delete(rawMsg, key) + case "class": + err = unpopulate(val, "Class", &b.Class) + delete(rawMsg, key) + case "features": + err = unpopulate(val, "Features", &b.Features) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &b.Path) + delete(rawMsg, key) + case "rpath": + err = unpopulate(val, "Rpath", &b.Rpath) + delete(rawMsg, key) + case "runpath": + err = unpopulate(val, "Runpath", &b.Runpath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BinaryHardeningFeatures. +func (b BinaryHardeningFeatures) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "canary", b.Canary) + populate(objectMap, "nx", b.Nx) + populate(objectMap, "pie", b.Pie) + populate(objectMap, "relro", b.Relro) + populate(objectMap, "stripped", b.Stripped) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BinaryHardeningFeatures. +func (b *BinaryHardeningFeatures) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "canary": + err = unpopulate(val, "Canary", &b.Canary) + delete(rawMsg, key) + case "nx": + err = unpopulate(val, "Nx", &b.Nx) + delete(rawMsg, key) + case "pie": + err = unpopulate(val, "Pie", &b.Pie) + delete(rawMsg, key) + case "relro": + err = unpopulate(val, "Relro", &b.Relro) + delete(rawMsg, key) + case "stripped": + err = unpopulate(val, "Stripped", &b.Stripped) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BinaryHardeningList. +func (b BinaryHardeningList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BinaryHardeningList. +func (b *BinaryHardeningList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BinaryHardeningSummary. +func (b BinaryHardeningSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "canary", b.Canary) + populate(objectMap, "nx", b.Nx) + populate(objectMap, "pie", b.Pie) + populate(objectMap, "relro", b.Relro) + populate(objectMap, "stripped", b.Stripped) + populate(objectMap, "totalFiles", b.TotalFiles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BinaryHardeningSummary. +func (b *BinaryHardeningSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "canary": + err = unpopulate(val, "Canary", &b.Canary) + delete(rawMsg, key) + case "nx": + err = unpopulate(val, "Nx", &b.Nx) + delete(rawMsg, key) + case "pie": + err = unpopulate(val, "Pie", &b.Pie) + delete(rawMsg, key) + case "relro": + err = unpopulate(val, "Relro", &b.Relro) + delete(rawMsg, key) + case "stripped": + err = unpopulate(val, "Stripped", &b.Stripped) + delete(rawMsg, key) + case "totalFiles": + err = unpopulate(val, "TotalFiles", &b.TotalFiles) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Component. +func (c Component) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "componentId", c.ComponentID) + populate(objectMap, "componentName", c.ComponentName) + populate(objectMap, "isUpdateAvailable", c.IsUpdateAvailable) + populate(objectMap, "license", c.License) + populate(objectMap, "paths", c.Paths) + populateTimeRFC3339(objectMap, "releaseDate", c.ReleaseDate) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Component. +func (c *Component) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "componentId": + err = unpopulate(val, "ComponentID", &c.ComponentID) + delete(rawMsg, key) + case "componentName": + err = unpopulate(val, "ComponentName", &c.ComponentName) + delete(rawMsg, key) + case "isUpdateAvailable": + err = unpopulate(val, "IsUpdateAvailable", &c.IsUpdateAvailable) + delete(rawMsg, key) + case "license": + err = unpopulate(val, "License", &c.License) + delete(rawMsg, key) + case "paths": + err = unpopulate(val, "Paths", &c.Paths) + delete(rawMsg, key) + case "releaseDate": + err = unpopulateTimeRFC3339(val, "ReleaseDate", &c.ReleaseDate) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &c.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ComponentList. +func (c ComponentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentList. +func (c *ComponentList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoCertificate. +func (c CryptoCertificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cryptoCertId", c.CryptoCertID) + populate(objectMap, "encoding", c.Encoding) + populateTimeRFC3339(objectMap, "expirationDate", c.ExpirationDate) + populate(objectMap, "filePaths", c.FilePaths) + populate(objectMap, "fingerprint", c.Fingerprint) + populate(objectMap, "isExpired", c.IsExpired) + populate(objectMap, "isSelfSigned", c.IsSelfSigned) + populate(objectMap, "isShortKeySize", c.IsShortKeySize) + populate(objectMap, "isWeakSignature", c.IsWeakSignature) + populateTimeRFC3339(objectMap, "issuedDate", c.IssuedDate) + populate(objectMap, "issuer", c.Issuer) + populate(objectMap, "keyAlgorithm", c.KeyAlgorithm) + populate(objectMap, "keySize", c.KeySize) + populate(objectMap, "name", c.Name) + populate(objectMap, "pairedKey", c.PairedKey) + populate(objectMap, "role", c.Role) + populate(objectMap, "serialNumber", c.SerialNumber) + populate(objectMap, "signatureAlgorithm", c.SignatureAlgorithm) + populate(objectMap, "subject", c.Subject) + populate(objectMap, "usage", c.Usage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoCertificate. +func (c *CryptoCertificate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cryptoCertId": + err = unpopulate(val, "CryptoCertID", &c.CryptoCertID) + delete(rawMsg, key) + case "encoding": + err = unpopulate(val, "Encoding", &c.Encoding) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateTimeRFC3339(val, "ExpirationDate", &c.ExpirationDate) + delete(rawMsg, key) + case "filePaths": + err = unpopulate(val, "FilePaths", &c.FilePaths) + delete(rawMsg, key) + case "fingerprint": + err = unpopulate(val, "Fingerprint", &c.Fingerprint) + delete(rawMsg, key) + case "isExpired": + err = unpopulate(val, "IsExpired", &c.IsExpired) + delete(rawMsg, key) + case "isSelfSigned": + err = unpopulate(val, "IsSelfSigned", &c.IsSelfSigned) + delete(rawMsg, key) + case "isShortKeySize": + err = unpopulate(val, "IsShortKeySize", &c.IsShortKeySize) + delete(rawMsg, key) + case "isWeakSignature": + err = unpopulate(val, "IsWeakSignature", &c.IsWeakSignature) + delete(rawMsg, key) + case "issuedDate": + err = unpopulateTimeRFC3339(val, "IssuedDate", &c.IssuedDate) + delete(rawMsg, key) + case "issuer": + err = unpopulate(val, "Issuer", &c.Issuer) + delete(rawMsg, key) + case "keyAlgorithm": + err = unpopulate(val, "KeyAlgorithm", &c.KeyAlgorithm) + delete(rawMsg, key) + case "keySize": + err = unpopulate(val, "KeySize", &c.KeySize) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "pairedKey": + err = unpopulate(val, "PairedKey", &c.PairedKey) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &c.Role) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &c.SerialNumber) + delete(rawMsg, key) + case "signatureAlgorithm": + err = unpopulate(val, "SignatureAlgorithm", &c.SignatureAlgorithm) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &c.Subject) + delete(rawMsg, key) + case "usage": + err = unpopulate(val, "Usage", &c.Usage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoCertificateEntity. +func (c CryptoCertificateEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "commonName", c.CommonName) + populate(objectMap, "country", c.Country) + populate(objectMap, "organization", c.Organization) + populate(objectMap, "organizationalUnit", c.OrganizationalUnit) + populate(objectMap, "state", c.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoCertificateEntity. +func (c *CryptoCertificateEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "commonName": + err = unpopulate(val, "CommonName", &c.CommonName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &c.Country) + delete(rawMsg, key) + case "organization": + err = unpopulate(val, "Organization", &c.Organization) + delete(rawMsg, key) + case "organizationalUnit": + err = unpopulate(val, "OrganizationalUnit", &c.OrganizationalUnit) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &c.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoCertificateList. +func (c CryptoCertificateList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoCertificateList. +func (c *CryptoCertificateList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoCertificateSummary. +func (c CryptoCertificateSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expired", c.Expired) + populate(objectMap, "expiringSoon", c.ExpiringSoon) + populate(objectMap, "pairedKeys", c.PairedKeys) + populate(objectMap, "selfSigned", c.SelfSigned) + populate(objectMap, "shortKeySize", c.ShortKeySize) + populate(objectMap, "totalCertificates", c.TotalCertificates) + populate(objectMap, "weakSignature", c.WeakSignature) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoCertificateSummary. +func (c *CryptoCertificateSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expired": + err = unpopulate(val, "Expired", &c.Expired) + delete(rawMsg, key) + case "expiringSoon": + err = unpopulate(val, "ExpiringSoon", &c.ExpiringSoon) + delete(rawMsg, key) + case "pairedKeys": + err = unpopulate(val, "PairedKeys", &c.PairedKeys) + delete(rawMsg, key) + case "selfSigned": + err = unpopulate(val, "SelfSigned", &c.SelfSigned) + delete(rawMsg, key) + case "shortKeySize": + err = unpopulate(val, "ShortKeySize", &c.ShortKeySize) + delete(rawMsg, key) + case "totalCertificates": + err = unpopulate(val, "TotalCertificates", &c.TotalCertificates) + delete(rawMsg, key) + case "weakSignature": + err = unpopulate(val, "WeakSignature", &c.WeakSignature) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoKey. +func (c CryptoKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cryptoKeyId", c.CryptoKeyID) + populate(objectMap, "filePaths", c.FilePaths) + populate(objectMap, "isShortKeySize", c.IsShortKeySize) + populate(objectMap, "keyAlgorithm", c.KeyAlgorithm) + populate(objectMap, "keySize", c.KeySize) + populate(objectMap, "keyType", c.KeyType) + populate(objectMap, "pairedKey", c.PairedKey) + populate(objectMap, "usage", c.Usage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoKey. +func (c *CryptoKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cryptoKeyId": + err = unpopulate(val, "CryptoKeyID", &c.CryptoKeyID) + delete(rawMsg, key) + case "filePaths": + err = unpopulate(val, "FilePaths", &c.FilePaths) + delete(rawMsg, key) + case "isShortKeySize": + err = unpopulate(val, "IsShortKeySize", &c.IsShortKeySize) + delete(rawMsg, key) + case "keyAlgorithm": + err = unpopulate(val, "KeyAlgorithm", &c.KeyAlgorithm) + delete(rawMsg, key) + case "keySize": + err = unpopulate(val, "KeySize", &c.KeySize) + delete(rawMsg, key) + case "keyType": + err = unpopulate(val, "KeyType", &c.KeyType) + delete(rawMsg, key) + case "pairedKey": + err = unpopulate(val, "PairedKey", &c.PairedKey) + delete(rawMsg, key) + case "usage": + err = unpopulate(val, "Usage", &c.Usage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoKeyList. +func (c CryptoKeyList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoKeyList. +func (c *CryptoKeyList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CryptoKeySummary. +func (c CryptoKeySummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "pairedKeys", c.PairedKeys) + populate(objectMap, "privateKeys", c.PrivateKeys) + populate(objectMap, "publicKeys", c.PublicKeys) + populate(objectMap, "shortKeySize", c.ShortKeySize) + populate(objectMap, "totalKeys", c.TotalKeys) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CryptoKeySummary. +func (c *CryptoKeySummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "pairedKeys": + err = unpopulate(val, "PairedKeys", &c.PairedKeys) + delete(rawMsg, key) + case "privateKeys": + err = unpopulate(val, "PrivateKeys", &c.PrivateKeys) + delete(rawMsg, key) + case "publicKeys": + err = unpopulate(val, "PublicKeys", &c.PublicKeys) + delete(rawMsg, key) + case "shortKeySize": + err = unpopulate(val, "ShortKeySize", &c.ShortKeySize) + delete(rawMsg, key) + case "totalKeys": + err = unpopulate(val, "TotalKeys", &c.TotalKeys) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Cve. +func (c Cve) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "component", c.Component) + populate(objectMap, "cveId", c.CveID) + populate(objectMap, "cvssScore", c.CvssScore) + populate(objectMap, "cvssV2Score", c.CvssV2Score) + populate(objectMap, "cvssV3Score", c.CvssV3Score) + populate(objectMap, "cvssVersion", c.CvssVersion) + populate(objectMap, "description", c.Description) + populate(objectMap, "links", c.Links) + populate(objectMap, "name", c.Name) + populateTimeRFC3339(objectMap, "publishDate", c.PublishDate) + populate(objectMap, "severity", c.Severity) + populateTimeRFC3339(objectMap, "updatedDate", c.UpdatedDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Cve. +func (c *Cve) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "component": + err = unpopulate(val, "Component", &c.Component) + delete(rawMsg, key) + case "cveId": + err = unpopulate(val, "CveID", &c.CveID) + delete(rawMsg, key) + case "cvssScore": + err = unpopulate(val, "CvssScore", &c.CvssScore) + delete(rawMsg, key) + case "cvssV2Score": + err = unpopulate(val, "CvssV2Score", &c.CvssV2Score) + delete(rawMsg, key) + case "cvssV3Score": + err = unpopulate(val, "CvssV3Score", &c.CvssV3Score) + delete(rawMsg, key) + case "cvssVersion": + err = unpopulate(val, "CvssVersion", &c.CvssVersion) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "links": + err = unpopulate(val, "Links", &c.Links) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "publishDate": + err = unpopulateTimeRFC3339(val, "PublishDate", &c.PublishDate) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &c.Severity) + delete(rawMsg, key) + case "updatedDate": + err = unpopulateTimeRFC3339(val, "UpdatedDate", &c.UpdatedDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CveLink. +func (c CveLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "href", c.Href) + populate(objectMap, "label", c.Label) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CveLink. +func (c *CveLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "href": + err = unpopulate(val, "Href", &c.Href) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &c.Label) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CveList. +func (c CveList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CveList. +func (c *CveList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CveSummary. +func (c CveSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "critical", c.Critical) + populate(objectMap, "high", c.High) + populate(objectMap, "low", c.Low) + populate(objectMap, "medium", c.Medium) + populate(objectMap, "undefined", c.Undefined) + populate(objectMap, "unknown", c.Unknown) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CveSummary. +func (c *CveSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "critical": + err = unpopulate(val, "Critical", &c.Critical) + delete(rawMsg, key) + case "high": + err = unpopulate(val, "High", &c.High) + delete(rawMsg, key) + case "low": + err = unpopulate(val, "Low", &c.Low) + delete(rawMsg, key) + case "medium": + err = unpopulate(val, "Medium", &c.Medium) + delete(rawMsg, key) + case "undefined": + err = unpopulate(val, "Undefined", &c.Undefined) + delete(rawMsg, key) + case "unknown": + err = unpopulate(val, "Unknown", &c.Unknown) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Firmware. +func (f Firmware) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Firmware. +func (f *Firmware) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirmwareList. +func (f FirmwareList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirmwareList. +func (f *FirmwareList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirmwareProperties. +func (f FirmwareProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", f.Description) + populate(objectMap, "fileName", f.FileName) + populate(objectMap, "fileSize", f.FileSize) + populate(objectMap, "model", f.Model) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "status", f.Status) + populate(objectMap, "statusMessages", f.StatusMessages) + populate(objectMap, "vendor", f.Vendor) + populate(objectMap, "version", f.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirmwareProperties. +func (f *FirmwareProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &f.Description) + delete(rawMsg, key) + case "fileName": + err = unpopulate(val, "FileName", &f.FileName) + delete(rawMsg, key) + case "fileSize": + err = unpopulate(val, "FileSize", &f.FileSize) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &f.Model) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &f.Status) + delete(rawMsg, key) + case "statusMessages": + err = unpopulate(val, "StatusMessages", &f.StatusMessages) + delete(rawMsg, key) + case "vendor": + err = unpopulate(val, "Vendor", &f.Vendor) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &f.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirmwareSummary. +func (f FirmwareSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "analysisTimeSeconds", f.AnalysisTimeSeconds) + populate(objectMap, "binaryCount", f.BinaryCount) + populate(objectMap, "componentCount", f.ComponentCount) + populate(objectMap, "extractedFileCount", f.ExtractedFileCount) + populate(objectMap, "extractedSize", f.ExtractedSize) + populate(objectMap, "fileSize", f.FileSize) + populate(objectMap, "rootFileSystems", f.RootFileSystems) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirmwareSummary. +func (f *FirmwareSummary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "analysisTimeSeconds": + err = unpopulate(val, "AnalysisTimeSeconds", &f.AnalysisTimeSeconds) + delete(rawMsg, key) + case "binaryCount": + err = unpopulate(val, "BinaryCount", &f.BinaryCount) + delete(rawMsg, key) + case "componentCount": + err = unpopulate(val, "ComponentCount", &f.ComponentCount) + delete(rawMsg, key) + case "extractedFileCount": + err = unpopulate(val, "ExtractedFileCount", &f.ExtractedFileCount) + delete(rawMsg, key) + case "extractedSize": + err = unpopulate(val, "ExtractedSize", &f.ExtractedSize) + delete(rawMsg, key) + case "fileSize": + err = unpopulate(val, "FileSize", &f.FileSize) + delete(rawMsg, key) + case "rootFileSystems": + err = unpopulate(val, "RootFileSystems", &f.RootFileSystems) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirmwareUpdateDefinition. +func (f FirmwareUpdateDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", f.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirmwareUpdateDefinition. +func (f *FirmwareUpdateDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateUploadURLRequest. +func (g GenerateUploadURLRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "firmwareId", g.FirmwareID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateUploadURLRequest. +func (g *GenerateUploadURLRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "firmwareId": + err = unpopulate(val, "FirmwareID", &g.FirmwareID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PairedKey. +func (p PairedKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "additionalProperties", p.AdditionalProperties) + populate(objectMap, "id", p.ID) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PairedKey. +func (p *PairedKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalProperties": + err = unpopulate(val, "AdditionalProperties", &p.AdditionalProperties) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PasswordHash. +func (p PasswordHash) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "algorithm", p.Algorithm) + populate(objectMap, "context", p.Context) + populate(objectMap, "filePath", p.FilePath) + populate(objectMap, "hash", p.Hash) + populate(objectMap, "passwordHashId", p.PasswordHashID) + populate(objectMap, "salt", p.Salt) + populate(objectMap, "username", p.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PasswordHash. +func (p *PasswordHash) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "algorithm": + err = unpopulate(val, "Algorithm", &p.Algorithm) + delete(rawMsg, key) + case "context": + err = unpopulate(val, "Context", &p.Context) + delete(rawMsg, key) + case "filePath": + err = unpopulate(val, "FilePath", &p.FilePath) + delete(rawMsg, key) + case "hash": + err = unpopulate(val, "Hash", &p.Hash) + delete(rawMsg, key) + case "passwordHashId": + err = unpopulate(val, "PasswordHashID", &p.PasswordHashID) + delete(rawMsg, key) + case "salt": + err = unpopulate(val, "Salt", &p.Salt) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &p.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PasswordHashList. +func (p PasswordHashList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PasswordHashList. +func (p *PasswordHashList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type URLToken. +func (u URLToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "url", u.URL) + populate(objectMap, "uploadUrl", u.UploadURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type URLToken. +func (u *URLToken) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "url": + err = unpopulate(val, "URL", &u.URL) + delete(rawMsg, key) + case "uploadUrl": + err = unpopulate(val, "UploadURL", &u.UploadURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "location", w.Location) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "tags", w.Tags) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Workspace. +func (w *Workspace) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &w.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceList. +func (w WorkspaceList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceList. +func (w *WorkspaceList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", w.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceProperties. +func (w *WorkspaceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceUpdateDefinition. +func (w WorkspaceUpdateDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceUpdateDefinition. +func (w *WorkspaceUpdateDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client.go new file mode 100644 index 000000000000..e8a2b4260a67 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Lists the operations for this resource provider +// +// Generated from API version 2023-02-08-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.IoTFirmwareDefense/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client_example_test.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client_example_test.go new file mode 100644 index 000000000000..3c096eb51d65 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/operations_client_example_test.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armiotfirmwaredefense.OperationListResult{ + // Value: []*armiotfirmwaredefense.Operation{ + // { + // Name: to.Ptr("fvpbaphlxaooymk"), + // ActionType: to.Ptr(armiotfirmwaredefense.ActionTypeInternal), + // Display: &armiotfirmwaredefense.OperationDisplay{ + // Description: to.Ptr("xxtlajuenswnnpgrivilipjqc"), + // Operation: to.Ptr("tcikadfeehm"), + // Provider: to.Ptr("hjnmhvyawkrqwpakyneaal"), + // Resource: to.Ptr("erhsibwfehcpdah"), + // }, + // IsDataAction: to.Ptr(true), + // Origin: to.Ptr(armiotfirmwaredefense.OriginUser), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armiotfirmwaredefense.OperationListResult{ + // } + } +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/response_types.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/response_types.go new file mode 100644 index 000000000000..33e10c77469a --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/response_types.go @@ -0,0 +1,150 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +// FirmwareClientCreateResponse contains the response from method FirmwareClient.Create. +type FirmwareClientCreateResponse struct { + Firmware +} + +// FirmwareClientDeleteResponse contains the response from method FirmwareClient.Delete. +type FirmwareClientDeleteResponse struct { + // placeholder for future response values +} + +// FirmwareClientGenerateBinaryHardeningDetailsResponse contains the response from method FirmwareClient.GenerateBinaryHardeningDetails. +type FirmwareClientGenerateBinaryHardeningDetailsResponse struct { + BinaryHardening +} + +// FirmwareClientGenerateBinaryHardeningSummaryResponse contains the response from method FirmwareClient.GenerateBinaryHardeningSummary. +type FirmwareClientGenerateBinaryHardeningSummaryResponse struct { + BinaryHardeningSummary +} + +// FirmwareClientGenerateComponentDetailsResponse contains the response from method FirmwareClient.GenerateComponentDetails. +type FirmwareClientGenerateComponentDetailsResponse struct { + Component +} + +// FirmwareClientGenerateCryptoCertificateSummaryResponse contains the response from method FirmwareClient.GenerateCryptoCertificateSummary. +type FirmwareClientGenerateCryptoCertificateSummaryResponse struct { + CryptoCertificateSummary +} + +// FirmwareClientGenerateCryptoKeySummaryResponse contains the response from method FirmwareClient.GenerateCryptoKeySummary. +type FirmwareClientGenerateCryptoKeySummaryResponse struct { + CryptoKeySummary +} + +// FirmwareClientGenerateCveSummaryResponse contains the response from method FirmwareClient.GenerateCveSummary. +type FirmwareClientGenerateCveSummaryResponse struct { + CveSummary +} + +// FirmwareClientGenerateDownloadURLResponse contains the response from method FirmwareClient.GenerateDownloadURL. +type FirmwareClientGenerateDownloadURLResponse struct { + URLToken +} + +// FirmwareClientGenerateFilesystemDownloadURLResponse contains the response from method FirmwareClient.GenerateFilesystemDownloadURL. +type FirmwareClientGenerateFilesystemDownloadURLResponse struct { + URLToken +} + +// FirmwareClientGenerateSummaryResponse contains the response from method FirmwareClient.GenerateSummary. +type FirmwareClientGenerateSummaryResponse struct { + FirmwareSummary +} + +// FirmwareClientGetResponse contains the response from method FirmwareClient.Get. +type FirmwareClientGetResponse struct { + Firmware +} + +// FirmwareClientListByWorkspaceResponse contains the response from method FirmwareClient.NewListByWorkspacePager. +type FirmwareClientListByWorkspaceResponse struct { + FirmwareList +} + +// FirmwareClientListGenerateBinaryHardeningListResponse contains the response from method FirmwareClient.NewListGenerateBinaryHardeningListPager. +type FirmwareClientListGenerateBinaryHardeningListResponse struct { + BinaryHardeningList +} + +// FirmwareClientListGenerateComponentListResponse contains the response from method FirmwareClient.NewListGenerateComponentListPager. +type FirmwareClientListGenerateComponentListResponse struct { + ComponentList +} + +// FirmwareClientListGenerateCryptoCertificateListResponse contains the response from method FirmwareClient.NewListGenerateCryptoCertificateListPager. +type FirmwareClientListGenerateCryptoCertificateListResponse struct { + CryptoCertificateList +} + +// FirmwareClientListGenerateCryptoKeyListResponse contains the response from method FirmwareClient.NewListGenerateCryptoKeyListPager. +type FirmwareClientListGenerateCryptoKeyListResponse struct { + CryptoKeyList +} + +// FirmwareClientListGenerateCveListResponse contains the response from method FirmwareClient.NewListGenerateCveListPager. +type FirmwareClientListGenerateCveListResponse struct { + CveList +} + +// FirmwareClientListGeneratePasswordHashListResponse contains the response from method FirmwareClient.NewListGeneratePasswordHashListPager. +type FirmwareClientListGeneratePasswordHashListResponse struct { + PasswordHashList +} + +// FirmwareClientUpdateResponse contains the response from method FirmwareClient.Update. +type FirmwareClientUpdateResponse struct { + Firmware +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + +// WorkspacesClientCreateResponse contains the response from method WorkspacesClient.Create. +type WorkspacesClientCreateResponse struct { + Workspace +} + +// WorkspacesClientDeleteResponse contains the response from method WorkspacesClient.Delete. +type WorkspacesClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspacesClientGenerateUploadURLResponse contains the response from method WorkspacesClient.GenerateUploadURL. +type WorkspacesClientGenerateUploadURLResponse struct { + URLToken +} + +// WorkspacesClientGetResponse contains the response from method WorkspacesClient.Get. +type WorkspacesClientGetResponse struct { + Workspace +} + +// WorkspacesClientListByResourceGroupResponse contains the response from method WorkspacesClient.NewListByResourceGroupPager. +type WorkspacesClientListByResourceGroupResponse struct { + WorkspaceList +} + +// WorkspacesClientListBySubscriptionResponse contains the response from method WorkspacesClient.NewListBySubscriptionPager. +type WorkspacesClientListBySubscriptionResponse struct { + WorkspaceList +} + +// WorkspacesClientUpdateResponse contains the response from method WorkspacesClient.Update. +type WorkspacesClientUpdateResponse struct { + Workspace +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/time_rfc3339.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/time_rfc3339.go new file mode 100644 index 000000000000..9fe4acace3c9 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/time_rfc3339.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client.go new file mode 100644 index 000000000000..e9894fc6b698 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client.go @@ -0,0 +1,450 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// 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" +) + +// WorkspacesClient contains the methods for the Workspaces group. +// Don't use this type directly, use NewWorkspacesClient() instead. +type WorkspacesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacesClient, error) { + cl, err := arm.NewClient(moduleName+".WorkspacesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspacesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Create - The operation to create or update a firmware analysis workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - workspace - Parameters when creating a firmware analysis workspace. +// - options - WorkspacesClientCreateOptions contains the optional parameters for the WorkspacesClient.Create method. +func (client *WorkspacesClient) Create(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace, options *WorkspacesClientCreateOptions) (WorkspacesClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, workspaceName, workspace, options) + if err != nil { + return WorkspacesClientCreateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return WorkspacesClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *WorkspacesClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace, options *WorkspacesClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, workspace) +} + +// createHandleResponse handles the Create response. +func (client *WorkspacesClient) createHandleResponse(resp *http.Response) (WorkspacesClientCreateResponse, error) { + result := WorkspacesClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientCreateResponse{}, err + } + return result, nil +} + +// Delete - The operation to delete a firmware analysis workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - options - WorkspacesClientDeleteOptions contains the optional parameters for the WorkspacesClient.Delete method. +func (client *WorkspacesClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesClientDeleteOptions) (WorkspacesClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesClientDeleteResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return WorkspacesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return WorkspacesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GenerateUploadURL - The operation to get a url for file upload. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - generateUploadURL - Parameters when requesting a URL to upload firmware. +// - options - WorkspacesClientGenerateUploadURLOptions contains the optional parameters for the WorkspacesClient.GenerateUploadURL +// method. +func (client *WorkspacesClient) GenerateUploadURL(ctx context.Context, resourceGroupName string, workspaceName string, generateUploadURL GenerateUploadURLRequest, options *WorkspacesClientGenerateUploadURLOptions) (WorkspacesClientGenerateUploadURLResponse, error) { + req, err := client.generateUploadURLCreateRequest(ctx, resourceGroupName, workspaceName, generateUploadURL, options) + if err != nil { + return WorkspacesClientGenerateUploadURLResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientGenerateUploadURLResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkspacesClientGenerateUploadURLResponse{}, runtime.NewResponseError(resp) + } + return client.generateUploadURLHandleResponse(resp) +} + +// generateUploadURLCreateRequest creates the GenerateUploadURL request. +func (client *WorkspacesClient) generateUploadURLCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, generateUploadURL GenerateUploadURLRequest, options *WorkspacesClientGenerateUploadURLOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}/generateUploadUrl" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, generateUploadURL) +} + +// generateUploadURLHandleResponse handles the GenerateUploadURL response. +func (client *WorkspacesClient) generateUploadURLHandleResponse(resp *http.Response) (WorkspacesClientGenerateUploadURLResponse, error) { + result := WorkspacesClientGenerateUploadURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.URLToken); err != nil { + return WorkspacesClientGenerateUploadURLResponse{}, err + } + return result, nil +} + +// Get - Get firmware analysis workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - options - WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesClientGetOptions) (WorkspacesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotModified) { + return WorkspacesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (WorkspacesClientGetResponse, error) { + result := WorkspacesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists all of the firmware analysis workspaces in the specified resource group. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - WorkspacesClientListByResourceGroupOptions contains the optional parameters for the WorkspacesClient.NewListByResourceGroupPager +// method. +func (client *WorkspacesClient) NewListByResourceGroupPager(resourceGroupName string, options *WorkspacesClientListByResourceGroupOptions) *runtime.Pager[WorkspacesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListByResourceGroupResponse]{ + More: func(page WorkspacesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacesClientListByResourceGroupResponse) (WorkspacesClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkspacesClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkspacesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkspacesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkspacesClientListByResourceGroupResponse, error) { + result := WorkspacesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceList); err != nil { + return WorkspacesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all of the firmware analysis workspaces in the specified subscription. +// +// Generated from API version 2023-02-08-preview +// - options - WorkspacesClientListBySubscriptionOptions contains the optional parameters for the WorkspacesClient.NewListBySubscriptionPager +// method. +func (client *WorkspacesClient) NewListBySubscriptionPager(options *WorkspacesClientListBySubscriptionOptions) *runtime.Pager[WorkspacesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListBySubscriptionResponse]{ + More: func(page WorkspacesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacesClientListBySubscriptionResponse) (WorkspacesClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkspacesClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkspacesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *WorkspacesClient) listBySubscriptionCreateRequest(ctx context.Context, options *WorkspacesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.IoTFirmwareDefense/workspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *WorkspacesClient) listBySubscriptionHandleResponse(resp *http.Response) (WorkspacesClientListBySubscriptionResponse, error) { + result := WorkspacesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceList); err != nil { + return WorkspacesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - The operation to update a firmware analysis workspaces. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-02-08-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the firmware analysis workspace. +// - workspace - Parameters when updating a firmware analysis workspace. +// - options - WorkspacesClientUpdateOptions contains the optional parameters for the WorkspacesClient.Update method. +func (client *WorkspacesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, workspace WorkspaceUpdateDefinition, options *WorkspacesClientUpdateOptions) (WorkspacesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, workspace, options) + if err != nil { + return WorkspacesClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return WorkspacesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, workspace WorkspaceUpdateDefinition, options *WorkspacesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTFirmwareDefense/workspaces/{workspaceName}" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-02-08-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, workspace) +} + +// updateHandleResponse handles the Update response. +func (client *WorkspacesClient) updateHandleResponse(resp *http.Response) (WorkspacesClientUpdateResponse, error) { + result := WorkspacesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client_example_test.go b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client_example_test.go new file mode 100644 index 000000000000..e650826ca157 --- /dev/null +++ b/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense/workspaces_client_example_test.go @@ -0,0 +1,456 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armiotfirmwaredefense_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotfirmwaredefense/armiotfirmwaredefense" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_ListBySubscription_MaximumSet_Gen.json +func ExampleWorkspacesClient_NewListBySubscriptionPager_workspacesListBySubscriptionMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkspacesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.WorkspaceList = armiotfirmwaredefense.WorkspaceList{ + // Value: []*armiotfirmwaredefense.Workspace{ + // { + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // CreatedBy: to.Ptr("kmgstbzxtl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // LastModifiedBy: to.Ptr("rfnhyhbyqzxnumjmjhwkhduztidk"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // Tags: map[string]*string{ + // "key450": to.Ptr("rzqqumbpfsbibnpirsm"), + // }, + // Properties: &armiotfirmwaredefense.WorkspaceProperties{ + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_ListBySubscription_MinimumSet_Gen.json +func ExampleWorkspacesClient_NewListBySubscriptionPager_workspacesListBySubscriptionMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkspacesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.WorkspaceList = armiotfirmwaredefense.WorkspaceList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_ListByResourceGroup_MaximumSet_Gen.json +func ExampleWorkspacesClient_NewListByResourceGroupPager_workspacesListByResourceGroupMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkspacesClient().NewListByResourceGroupPager("rgworkspaces", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.WorkspaceList = armiotfirmwaredefense.WorkspaceList{ + // Value: []*armiotfirmwaredefense.Workspace{ + // { + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // CreatedBy: to.Ptr("kmgstbzxtl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // LastModifiedBy: to.Ptr("rfnhyhbyqzxnumjmjhwkhduztidk"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // Tags: map[string]*string{ + // "key450": to.Ptr("rzqqumbpfsbibnpirsm"), + // }, + // Properties: &armiotfirmwaredefense.WorkspaceProperties{ + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_ListByResourceGroup_MinimumSet_Gen.json +func ExampleWorkspacesClient_NewListByResourceGroupPager_workspacesListByResourceGroupMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkspacesClient().NewListByResourceGroupPager("rgworkspaces", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.WorkspaceList = armiotfirmwaredefense.WorkspaceList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Create_MaximumSet_Gen.json +func ExampleWorkspacesClient_Create_workspacesCreateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Create(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.Workspace{ + Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + Tags: map[string]*string{ + "key450": to.Ptr("rzqqumbpfsbibnpirsm"), + }, + Properties: &armiotfirmwaredefense.WorkspaceProperties{}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // CreatedBy: to.Ptr("kmgstbzxtl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // LastModifiedBy: to.Ptr("rfnhyhbyqzxnumjmjhwkhduztidk"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // Tags: map[string]*string{ + // "key450": to.Ptr("rzqqumbpfsbibnpirsm"), + // }, + // Properties: &armiotfirmwaredefense.WorkspaceProperties{ + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Create_MinimumSet_Gen.json +func ExampleWorkspacesClient_Create_workspacesCreateMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Create(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.Workspace{ + Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Update_MaximumSet_Gen.json +func ExampleWorkspacesClient_Update_workspacesUpdateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Update(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.WorkspaceUpdateDefinition{ + Properties: &armiotfirmwaredefense.WorkspaceProperties{}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // CreatedBy: to.Ptr("kmgstbzxtl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-02-19T05:35:25.545Z"); return t}()), + // LastModifiedBy: to.Ptr("rfnhyhbyqzxnumjmjhwkhduztidk"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // Tags: map[string]*string{ + // "key450": to.Ptr("rzqqumbpfsbibnpirsm"), + // }, + // Properties: &armiotfirmwaredefense.WorkspaceProperties{ + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Update_MinimumSet_Gen.json +func ExampleWorkspacesClient_Update_workspacesUpdateMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Update(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.WorkspaceUpdateDefinition{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Location: to.Ptr("jjwbseilitjgdrhbvvkwviqj"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Delete_MaximumSet_Gen.json +func ExampleWorkspacesClient_Delete_workspacesDeleteMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewWorkspacesClient().Delete(ctx, "rgworkspaces", "E___-3", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Delete_MinimumSet_Gen.json +func ExampleWorkspacesClient_Delete_workspacesDeleteMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewWorkspacesClient().Delete(ctx, "rgworkspaces", "E___-3", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Get_MaximumSet_Gen.json +func ExampleWorkspacesClient_Get_workspacesGetMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Get(ctx, "rgworkspaces", "E_US", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Name: to.Ptr("vbgktdhddtb"), + // Type: to.Ptr("ux"), + // ID: to.Ptr("vdqbannpvrsembsinbyaupmpxsdi"), + // SystemData: &armiotfirmwaredefense.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-21T14:59:45.580Z"); return t}()), + // CreatedBy: to.Ptr("vnrbl"), + // CreatedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-21T14:59:45.580Z"); return t}()), + // LastModifiedBy: to.Ptr("zmmusinjpfjqy"), + // LastModifiedByType: to.Ptr(armiotfirmwaredefense.CreatedByTypeUser), + // }, + // Location: to.Ptr("zxwrauqottoy"), + // Tags: map[string]*string{ + // "key6364": to.Ptr("itpmlxzoingnevgitv"), + // }, + // Properties: &armiotfirmwaredefense.WorkspaceProperties{ + // ProvisioningState: to.Ptr(armiotfirmwaredefense.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_Get_MinimumSet_Gen.json +func ExampleWorkspacesClient_Get_workspacesGetMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Get(ctx, "rgworkspaces", "E_US", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Workspace = armiotfirmwaredefense.Workspace{ + // Name: to.Ptr("tbrqhnzpsatbrnhtj"), + // Type: to.Ptr("angrpzpxmuppzqpzpljasjirao"), + // ID: to.Ptr("uuuwv"), + // Location: to.Ptr("zxwrauqottoy"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_GenerateUploadUrl_MaximumSet_Gen.json +func ExampleWorkspacesClient_GenerateUploadURL_workspacesGenerateUploadUrlMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().GenerateUploadURL(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.GenerateUploadURLRequest{ + FirmwareID: to.Ptr("ytsfprbywi"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // UploadURL: to.Ptr("https://i/am/a/sas/token/too"), + // URL: to.Ptr("https://i/am/a/sas/token"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/preview/2023-02-08-preview/examples/Workspaces_GenerateUploadUrl_MinimumSet_Gen.json +func ExampleWorkspacesClient_GenerateUploadURL_workspacesGenerateUploadUrlMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armiotfirmwaredefense.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().GenerateUploadURL(ctx, "rgworkspaces", "E___-3", armiotfirmwaredefense.GenerateUploadURLRequest{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.URLToken = armiotfirmwaredefense.URLToken{ + // } +}