From 71411979b71aac9da632307add38a64ce5b03444 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 19 Jul 2023 09:04:23 +0000 Subject: [PATCH] CodeGen from PR 24895 in Azure/azure-rest-api-specs Merge f7a4b3be4d6f953d4048f672a24046cbac1ecad9 into 14a3cf043a4567366366f3d70829b4ef57711eb3 --- .../azuresphere/armazuresphere/CHANGELOG.md | 7 + .../azuresphere/armazuresphere/LICENSE.txt | 21 + .../azuresphere/armazuresphere/README.md | 85 + .../azuresphere/armazuresphere/autorest.md | 13 + .../azuresphere/armazuresphere/build.go | 7 + .../armazuresphere/catalogs_client.go | 814 +++++++++ .../armazuresphere/certificates_client.go | 325 ++++ .../azuresphere/armazuresphere/ci.yml | 28 + .../armazuresphere/client_factory.go | 87 + .../azuresphere/armazuresphere/constants.go | 307 ++++ .../armazuresphere/deployments_client.go | 391 ++++ .../armazuresphere/devicegroups_client.go | 598 +++++++ .../armazuresphere/devices_client.go | 544 ++++++ .../azuresphere/armazuresphere/go.mod | 13 + .../azuresphere/armazuresphere/go.sum | 15 + .../armazuresphere/images_client.go | 342 ++++ .../azuresphere/armazuresphere/models.go | 881 +++++++++ .../armazuresphere/models_serde.go | 1571 +++++++++++++++++ .../armazuresphere/operations_client.go | 102 ++ .../armazuresphere/products_client.go | 542 ++++++ .../armazuresphere/response_types.go | 238 +++ .../armazuresphere/time_rfc3339.go | 95 + 22 files changed, 7026 insertions(+) create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/CHANGELOG.md create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/LICENSE.txt create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/README.md create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/autorest.md create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/build.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/catalogs_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/certificates_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/ci.yml create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/client_factory.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/constants.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/deployments_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/devicegroups_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/devices_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/go.mod create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/go.sum create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/images_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/models.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/models_serde.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/operations_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/products_client.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/response_types.go create mode 100644 sdk/resourcemanager/azuresphere/armazuresphere/time_rfc3339.go diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/CHANGELOG.md b/sdk/resourcemanager/azuresphere/armazuresphere/CHANGELOG.md new file mode 100644 index 000000000000..b83410e54991 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-07-19) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuresphere/armazuresphere` 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/azuresphere/armazuresphere/LICENSE.txt b/sdk/resourcemanager/azuresphere/armazuresphere/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/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/azuresphere/armazuresphere/README.md b/sdk/resourcemanager/azuresphere/armazuresphere/README.md new file mode 100644 index 000000000000..a66f33686a39 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/README.md @@ -0,0 +1,85 @@ +# Azure Azuresphere Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuresphere/armazuresphere)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuresphere/armazuresphere) + +The `armazuresphere` module provides operations for working with Azure Azuresphere. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/azuresphere/armazuresphere) + +# 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 Azuresphere module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuresphere/armazuresphere +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Azuresphere. 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 Azuresphere 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 := armazuresphere.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 := armazuresphere.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.NewProductsClient() +``` + +## 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 `Azuresphere` 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/azuresphere/armazuresphere/autorest.md b/sdk/resourcemanager/azuresphere/armazuresphere/autorest.md new file mode 100644 index 000000000000..c74ac22db1cf --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/sphere/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/sphere/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/build.go b/sdk/resourcemanager/azuresphere/armazuresphere/build.go new file mode 100644 index 000000000000..585e46e06367 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/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/azuresphere/armazuresphere + +package armazuresphere diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/catalogs_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/catalogs_client.go new file mode 100644 index 000000000000..c1c1b0c15cc3 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/catalogs_client.go @@ -0,0 +1,814 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" + "strconv" + "strings" +) + +// CatalogsClient contains the methods for the Catalogs group. +// Don't use this type directly, use NewCatalogsClient() instead. +type CatalogsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCatalogsClient creates a new instance of CatalogsClient 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 NewCatalogsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CatalogsClient, error) { + cl, err := arm.NewClient(moduleName+".CatalogsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CatalogsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CountDevices - Counts devices in catalog. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientCountDevicesOptions contains the optional parameters for the CatalogsClient.CountDevices method. +func (client *CatalogsClient) CountDevices(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientCountDevicesOptions) (CatalogsClientCountDevicesResponse, error) { + req, err := client.countDevicesCreateRequest(ctx, resourceGroupName, catalogName, options) + if err != nil { + return CatalogsClientCountDevicesResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientCountDevicesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientCountDevicesResponse{}, runtime.NewResponseError(resp) + } + return client.countDevicesHandleResponse(resp) +} + +// countDevicesCreateRequest creates the CountDevices request. +func (client *CatalogsClient) countDevicesCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientCountDevicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/countDevices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// countDevicesHandleResponse handles the CountDevices response. +func (client *CatalogsClient) countDevicesHandleResponse(resp *http.Response) (CatalogsClientCountDevicesResponse, error) { + result := CatalogsClientCountDevicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CountDeviceResponse); err != nil { + return CatalogsClientCountDevicesResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - resource - Resource create parameters. +// - options - CatalogsClientBeginCreateOrUpdateOptions contains the optional parameters for the CatalogsClient.BeginCreateOrUpdate +// method. +func (client *CatalogsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, resource Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CatalogsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CatalogsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *CatalogsClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, resource Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CatalogsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, resource Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientBeginDeleteOptions contains the optional parameters for the CatalogsClient.BeginDelete method. +func (client *CatalogsClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*runtime.Poller[CatalogsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CatalogsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *CatalogsClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CatalogsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientGetOptions contains the optional parameters for the CatalogsClient.Get method. +func (client *CatalogsClient) Get(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientGetOptions) (CatalogsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, options) + if err != nil { + return CatalogsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CatalogsClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CatalogsClient) getHandleResponse(resp *http.Response) (CatalogsClientGetResponse, error) { + result := CatalogsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Catalog); err != nil { + return CatalogsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List Catalog resources by resource group +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CatalogsClientListByResourceGroupOptions contains the optional parameters for the CatalogsClient.NewListByResourceGroupPager +// method. +func (client *CatalogsClient) NewListByResourceGroupPager(resourceGroupName string, options *CatalogsClientListByResourceGroupOptions) *runtime.Pager[CatalogsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListByResourceGroupResponse]{ + More: func(page CatalogsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListByResourceGroupResponse) (CatalogsClientListByResourceGroupResponse, 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 CatalogsClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CatalogsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CatalogsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs" + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CatalogsClient) listByResourceGroupHandleResponse(resp *http.Response) (CatalogsClientListByResourceGroupResponse, error) { + result := CatalogsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CatalogListResult); err != nil { + return CatalogsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Catalog resources by subscription ID +// +// Generated from API version 2022-09-01-preview +// - options - CatalogsClientListBySubscriptionOptions contains the optional parameters for the CatalogsClient.NewListBySubscriptionPager +// method. +func (client *CatalogsClient) NewListBySubscriptionPager(options *CatalogsClientListBySubscriptionOptions) *runtime.Pager[CatalogsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListBySubscriptionResponse]{ + More: func(page CatalogsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListBySubscriptionResponse) (CatalogsClientListBySubscriptionResponse, 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 CatalogsClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CatalogsClient) listBySubscriptionCreateRequest(ctx context.Context, options *CatalogsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureSphere/catalogs" + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CatalogsClient) listBySubscriptionHandleResponse(resp *http.Response) (CatalogsClientListBySubscriptionResponse, error) { + result := CatalogsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CatalogListResult); err != nil { + return CatalogsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// NewListDeploymentsPager - Lists deployments for catalog. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientListDeploymentsOptions contains the optional parameters for the CatalogsClient.NewListDeploymentsPager +// method. +func (client *CatalogsClient) NewListDeploymentsPager(resourceGroupName string, catalogName string, options *CatalogsClientListDeploymentsOptions) *runtime.Pager[CatalogsClientListDeploymentsResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListDeploymentsResponse]{ + More: func(page CatalogsClientListDeploymentsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListDeploymentsResponse) (CatalogsClientListDeploymentsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listDeploymentsCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CatalogsClientListDeploymentsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListDeploymentsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListDeploymentsResponse{}, runtime.NewResponseError(resp) + } + return client.listDeploymentsHandleResponse(resp) + }, + }) +} + +// listDeploymentsCreateRequest creates the ListDeployments request. +func (client *CatalogsClient) listDeploymentsCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientListDeploymentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeployments" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listDeploymentsHandleResponse handles the ListDeployments response. +func (client *CatalogsClient) listDeploymentsHandleResponse(resp *http.Response) (CatalogsClientListDeploymentsResponse, error) { + result := CatalogsClientListDeploymentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { + return CatalogsClientListDeploymentsResponse{}, err + } + return result, nil +} + +// NewListDeviceGroupsPager - List the device groups for the catalog. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - listDeviceGroupsRequest - List device groups for catalog. +// - options - CatalogsClientListDeviceGroupsOptions contains the optional parameters for the CatalogsClient.NewListDeviceGroupsPager +// method. +func (client *CatalogsClient) NewListDeviceGroupsPager(resourceGroupName string, catalogName string, listDeviceGroupsRequest ListDeviceGroupsRequest, options *CatalogsClientListDeviceGroupsOptions) *runtime.Pager[CatalogsClientListDeviceGroupsResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListDeviceGroupsResponse]{ + More: func(page CatalogsClientListDeviceGroupsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListDeviceGroupsResponse) (CatalogsClientListDeviceGroupsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listDeviceGroupsCreateRequest(ctx, resourceGroupName, catalogName, listDeviceGroupsRequest, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CatalogsClientListDeviceGroupsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListDeviceGroupsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListDeviceGroupsResponse{}, runtime.NewResponseError(resp) + } + return client.listDeviceGroupsHandleResponse(resp) + }, + }) +} + +// listDeviceGroupsCreateRequest creates the ListDeviceGroups request. +func (client *CatalogsClient) listDeviceGroupsCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, listDeviceGroupsRequest ListDeviceGroupsRequest, options *CatalogsClientListDeviceGroupsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceGroups" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, listDeviceGroupsRequest) +} + +// listDeviceGroupsHandleResponse handles the ListDeviceGroups response. +func (client *CatalogsClient) listDeviceGroupsHandleResponse(resp *http.Response) (CatalogsClientListDeviceGroupsResponse, error) { + result := CatalogsClientListDeviceGroupsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceGroupListResult); err != nil { + return CatalogsClientListDeviceGroupsResponse{}, err + } + return result, nil +} + +// NewListDeviceInsightsPager - Lists device insights for catalog. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientListDeviceInsightsOptions contains the optional parameters for the CatalogsClient.NewListDeviceInsightsPager +// method. +func (client *CatalogsClient) NewListDeviceInsightsPager(resourceGroupName string, catalogName string, options *CatalogsClientListDeviceInsightsOptions) *runtime.Pager[CatalogsClientListDeviceInsightsResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListDeviceInsightsResponse]{ + More: func(page CatalogsClientListDeviceInsightsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListDeviceInsightsResponse) (CatalogsClientListDeviceInsightsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listDeviceInsightsCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CatalogsClientListDeviceInsightsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListDeviceInsightsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListDeviceInsightsResponse{}, runtime.NewResponseError(resp) + } + return client.listDeviceInsightsHandleResponse(resp) + }, + }) +} + +// listDeviceInsightsCreateRequest creates the ListDeviceInsights request. +func (client *CatalogsClient) listDeviceInsightsCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientListDeviceInsightsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceInsights" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listDeviceInsightsHandleResponse handles the ListDeviceInsights response. +func (client *CatalogsClient) listDeviceInsightsHandleResponse(resp *http.Response) (CatalogsClientListDeviceInsightsResponse, error) { + result := CatalogsClientListDeviceInsightsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedDeviceInsight); err != nil { + return CatalogsClientListDeviceInsightsResponse{}, err + } + return result, nil +} + +// NewListDevicesPager - Lists devices for catalog. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CatalogsClientListDevicesOptions contains the optional parameters for the CatalogsClient.NewListDevicesPager +// method. +func (client *CatalogsClient) NewListDevicesPager(resourceGroupName string, catalogName string, options *CatalogsClientListDevicesOptions) *runtime.Pager[CatalogsClientListDevicesResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListDevicesResponse]{ + More: func(page CatalogsClientListDevicesResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListDevicesResponse) (CatalogsClientListDevicesResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listDevicesCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CatalogsClientListDevicesResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientListDevicesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListDevicesResponse{}, runtime.NewResponseError(resp) + } + return client.listDevicesHandleResponse(resp) + }, + }) +} + +// listDevicesCreateRequest creates the ListDevices request. +func (client *CatalogsClient) listDevicesCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CatalogsClientListDevicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDevices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listDevicesHandleResponse handles the ListDevices response. +func (client *CatalogsClient) listDevicesHandleResponse(resp *http.Response) (CatalogsClientListDevicesResponse, error) { + result := CatalogsClientListDevicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceListResult); err != nil { + return CatalogsClientListDevicesResponse{}, err + } + return result, nil +} + +// Update - Update a Catalog +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - properties - The resource properties to be updated. +// - options - CatalogsClientUpdateOptions contains the optional parameters for the CatalogsClient.Update method. +func (client *CatalogsClient) Update(ctx context.Context, resourceGroupName string, catalogName string, properties CatalogUpdate, options *CatalogsClientUpdateOptions) (CatalogsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, catalogName, properties, options) + if err != nil { + return CatalogsClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CatalogsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CatalogsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, properties CatalogUpdate, options *CatalogsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *CatalogsClient) updateHandleResponse(resp *http.Response) (CatalogsClientUpdateResponse, error) { + result := CatalogsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Catalog); err != nil { + return CatalogsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/certificates_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/certificates_client.go new file mode 100644 index 000000000000..e538fc012113 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/certificates_client.go @@ -0,0 +1,325 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" + "strconv" + "strings" +) + +// CertificatesClient contains the methods for the Certificates group. +// Don't use this type directly, use NewCertificatesClient() instead. +type CertificatesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCertificatesClient creates a new instance of CertificatesClient 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 NewCertificatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CertificatesClient, error) { + cl, err := arm.NewClient(moduleName+".CertificatesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CertificatesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get a Certificate +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - serialNumber - Serial number of the certificate. Use '.default' to get current active certificate. +// - options - CertificatesClientGetOptions contains the optional parameters for the CertificatesClient.Get method. +func (client *CertificatesClient) Get(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, options *CertificatesClientGetOptions) (CertificatesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, serialNumber, options) + if err != nil { + return CertificatesClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CertificatesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CertificatesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CertificatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, options *CertificatesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if serialNumber == "" { + return nil, errors.New("parameter serialNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serialNumber}", url.PathEscape(serialNumber)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CertificatesClient) getHandleResponse(resp *http.Response) (CertificatesClientGetResponse, error) { + result := CertificatesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Certificate); err != nil { + return CertificatesClientGetResponse{}, err + } + return result, nil +} + +// NewListByCatalogPager - List Certificate resources by Catalog +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - CertificatesClientListByCatalogOptions contains the optional parameters for the CertificatesClient.NewListByCatalogPager +// method. +func (client *CertificatesClient) NewListByCatalogPager(resourceGroupName string, catalogName string, options *CertificatesClientListByCatalogOptions) *runtime.Pager[CertificatesClientListByCatalogResponse] { + return runtime.NewPager(runtime.PagingHandler[CertificatesClientListByCatalogResponse]{ + More: func(page CertificatesClientListByCatalogResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CertificatesClientListByCatalogResponse) (CertificatesClientListByCatalogResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByCatalogCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CertificatesClientListByCatalogResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CertificatesClientListByCatalogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CertificatesClientListByCatalogResponse{}, runtime.NewResponseError(resp) + } + return client.listByCatalogHandleResponse(resp) + }, + }) +} + +// listByCatalogCreateRequest creates the ListByCatalog request. +func (client *CertificatesClient) listByCatalogCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *CertificatesClientListByCatalogOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + reqQP.Set("api-version", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCatalogHandleResponse handles the ListByCatalog response. +func (client *CertificatesClient) listByCatalogHandleResponse(resp *http.Response) (CertificatesClientListByCatalogResponse, error) { + result := CertificatesClientListByCatalogResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateListResult); err != nil { + return CertificatesClientListByCatalogResponse{}, err + } + return result, nil +} + +// RetrieveCertChain - Retrieves cert chain. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - serialNumber - Serial number of the certificate. Use '.default' to get current active certificate. +// - options - CertificatesClientRetrieveCertChainOptions contains the optional parameters for the CertificatesClient.RetrieveCertChain +// method. +func (client *CertificatesClient) RetrieveCertChain(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, options *CertificatesClientRetrieveCertChainOptions) (CertificatesClientRetrieveCertChainResponse, error) { + req, err := client.retrieveCertChainCreateRequest(ctx, resourceGroupName, catalogName, serialNumber, options) + if err != nil { + return CertificatesClientRetrieveCertChainResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CertificatesClientRetrieveCertChainResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CertificatesClientRetrieveCertChainResponse{}, runtime.NewResponseError(resp) + } + return client.retrieveCertChainHandleResponse(resp) +} + +// retrieveCertChainCreateRequest creates the RetrieveCertChain request. +func (client *CertificatesClient) retrieveCertChainCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, options *CertificatesClientRetrieveCertChainOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveCertChain" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if serialNumber == "" { + return nil, errors.New("parameter serialNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serialNumber}", url.PathEscape(serialNumber)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// retrieveCertChainHandleResponse handles the RetrieveCertChain response. +func (client *CertificatesClient) retrieveCertChainHandleResponse(resp *http.Response) (CertificatesClientRetrieveCertChainResponse, error) { + result := CertificatesClientRetrieveCertChainResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateChainResponse); err != nil { + return CertificatesClientRetrieveCertChainResponse{}, err + } + return result, nil +} + +// RetrieveProofOfPossessionNonce - Gets the proof of possession nonce. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - serialNumber - Serial number of the certificate. Use '.default' to get current active certificate. +// - proofOfPossessionNonceRequest - Proof of possession nonce request body +// - options - CertificatesClientRetrieveProofOfPossessionNonceOptions contains the optional parameters for the CertificatesClient.RetrieveProofOfPossessionNonce +// method. +func (client *CertificatesClient) RetrieveProofOfPossessionNonce(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, proofOfPossessionNonceRequest ProofOfPossessionNonceRequest, options *CertificatesClientRetrieveProofOfPossessionNonceOptions) (CertificatesClientRetrieveProofOfPossessionNonceResponse, error) { + req, err := client.retrieveProofOfPossessionNonceCreateRequest(ctx, resourceGroupName, catalogName, serialNumber, proofOfPossessionNonceRequest, options) + if err != nil { + return CertificatesClientRetrieveProofOfPossessionNonceResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CertificatesClientRetrieveProofOfPossessionNonceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CertificatesClientRetrieveProofOfPossessionNonceResponse{}, runtime.NewResponseError(resp) + } + return client.retrieveProofOfPossessionNonceHandleResponse(resp) +} + +// retrieveProofOfPossessionNonceCreateRequest creates the RetrieveProofOfPossessionNonce request. +func (client *CertificatesClient) retrieveProofOfPossessionNonceCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, serialNumber string, proofOfPossessionNonceRequest ProofOfPossessionNonceRequest, options *CertificatesClientRetrieveProofOfPossessionNonceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveProofOfPossessionNonce" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if serialNumber == "" { + return nil, errors.New("parameter serialNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serialNumber}", url.PathEscape(serialNumber)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, proofOfPossessionNonceRequest) +} + +// retrieveProofOfPossessionNonceHandleResponse handles the RetrieveProofOfPossessionNonce response. +func (client *CertificatesClient) retrieveProofOfPossessionNonceHandleResponse(resp *http.Response) (CertificatesClientRetrieveProofOfPossessionNonceResponse, error) { + result := CertificatesClientRetrieveProofOfPossessionNonceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProofOfPossessionNonceResponse); err != nil { + return CertificatesClientRetrieveProofOfPossessionNonceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/ci.yml b/sdk/resourcemanager/azuresphere/armazuresphere/ci.yml new file mode 100644 index 000000000000..f2a7e03cf06a --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/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/azuresphere/armazuresphere/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azuresphere/armazuresphere/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/azuresphere/armazuresphere' diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/client_factory.go b/sdk/resourcemanager/azuresphere/armazuresphere/client_factory.go new file mode 100644 index 000000000000..5f3308d5bd0e --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/client_factory.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCatalogsClient() *CatalogsClient { + subClient, _ := NewCatalogsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCertificatesClient() *CertificatesClient { + subClient, _ := NewCertificatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewImagesClient() *ImagesClient { + subClient, _ := NewImagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProductsClient() *ProductsClient { + subClient, _ := NewProductsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeviceGroupsClient() *DeviceGroupsClient { + subClient, _ := NewDeviceGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { + subClient, _ := NewDeploymentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDevicesClient() *DevicesClient { + subClient, _ := NewDevicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/constants.go b/sdk/resourcemanager/azuresphere/armazuresphere/constants.go new file mode 100644 index 000000000000..afc601b05f43 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/constants.go @@ -0,0 +1,307 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +const ( + moduleName = "armazuresphere" + 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, + } +} + +// AllowCrashDumpCollection - Allow crash dumps values. +type AllowCrashDumpCollection string + +const ( + // AllowCrashDumpCollectionDisabled - Crash dump collection disabled + AllowCrashDumpCollectionDisabled AllowCrashDumpCollection = "Disabled" + // AllowCrashDumpCollectionEnabled - Crash dump collection enabled + AllowCrashDumpCollectionEnabled AllowCrashDumpCollection = "Enabled" +) + +// PossibleAllowCrashDumpCollectionValues returns the possible values for the AllowCrashDumpCollection const type. +func PossibleAllowCrashDumpCollectionValues() []AllowCrashDumpCollection { + return []AllowCrashDumpCollection{ + AllowCrashDumpCollectionDisabled, + AllowCrashDumpCollectionEnabled, + } +} + +// CapabilityType - Capability image type +type CapabilityType string + +const ( + // CapabilityTypeApplicationDevelopment - Application development capability + CapabilityTypeApplicationDevelopment CapabilityType = "ApplicationDevelopment" + // CapabilityTypeFieldServicing - Field servicing capability + CapabilityTypeFieldServicing CapabilityType = "FieldServicing" +) + +// PossibleCapabilityTypeValues returns the possible values for the CapabilityType const type. +func PossibleCapabilityTypeValues() []CapabilityType { + return []CapabilityType{ + CapabilityTypeApplicationDevelopment, + CapabilityTypeFieldServicing, + } +} + +// CertificateStatus - Certificate status values. +type CertificateStatus string + +const ( + // CertificateStatusActive - Certificate is active + CertificateStatusActive CertificateStatus = "Active" + // CertificateStatusExpired - Certificate has expired + CertificateStatusExpired CertificateStatus = "Expired" + // CertificateStatusInactive - Certificate is inactive + CertificateStatusInactive CertificateStatus = "Inactive" + // CertificateStatusRevoked - Certificate has been revoked + CertificateStatusRevoked CertificateStatus = "Revoked" +) + +// PossibleCertificateStatusValues returns the possible values for the CertificateStatus const type. +func PossibleCertificateStatusValues() []CertificateStatus { + return []CertificateStatus{ + CertificateStatusActive, + CertificateStatusExpired, + CertificateStatusInactive, + CertificateStatusRevoked, + } +} + +// 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, + } +} + +// ImageType - Image type values. +type ImageType string + +const ( + // ImageTypeApplications - Applications image type + ImageTypeApplications ImageType = "Applications" + // ImageTypeBaseSystemUpdateManifest - Base system update manifest image type + ImageTypeBaseSystemUpdateManifest ImageType = "BaseSystemUpdateManifest" + // ImageTypeBootManifest - Boot manifest image type + ImageTypeBootManifest ImageType = "BootManifest" + // ImageTypeCustomerBoardConfig - Customer board config image type + ImageTypeCustomerBoardConfig ImageType = "CustomerBoardConfig" + // ImageTypeCustomerUpdateManifest - Customer update manifest image type + ImageTypeCustomerUpdateManifest ImageType = "CustomerUpdateManifest" + // ImageTypeFirmwareUpdateManifest - Firmware update manifest image type + ImageTypeFirmwareUpdateManifest ImageType = "FirmwareUpdateManifest" + // ImageTypeFwConfig - FW config image type + ImageTypeFwConfig ImageType = "FwConfig" + // ImageTypeInvalidImageType - Invalid image. + ImageTypeInvalidImageType ImageType = "InvalidImageType" + // ImageTypeManifestSet - manifest set image type + ImageTypeManifestSet ImageType = "ManifestSet" + // ImageTypeNormalWorldDtb - Normal world dtb image type + ImageTypeNormalWorldDtb ImageType = "NormalWorldDtb" + // ImageTypeNormalWorldKernel - Normal world kernel image type + ImageTypeNormalWorldKernel ImageType = "NormalWorldKernel" + // ImageTypeNormalWorldLoader - Normal world loader image type + ImageTypeNormalWorldLoader ImageType = "NormalWorldLoader" + // ImageTypeNwfs - Nwfs image type + ImageTypeNwfs ImageType = "Nwfs" + // ImageTypeOneBl - One Bl image type + ImageTypeOneBl ImageType = "OneBl" + // ImageTypeOther - Other image type + ImageTypeOther ImageType = "Other" + // ImageTypePlutonRuntime - Pluton image type + ImageTypePlutonRuntime ImageType = "PlutonRuntime" + // ImageTypePolicy - Policy image type + ImageTypePolicy ImageType = "Policy" + // ImageTypeRecoveryManifest - Recovery manifest image type + ImageTypeRecoveryManifest ImageType = "RecoveryManifest" + // ImageTypeRootFs - Root FS image type + ImageTypeRootFs ImageType = "RootFs" + // ImageTypeSecurityMonitor - Security monitor image type + ImageTypeSecurityMonitor ImageType = "SecurityMonitor" + // ImageTypeServices - Services image type + ImageTypeServices ImageType = "Services" + // ImageTypeTrustedKeystore - Trusted key store image type + ImageTypeTrustedKeystore ImageType = "TrustedKeystore" + // ImageTypeUpdateCertStore - Update certificate store image type + ImageTypeUpdateCertStore ImageType = "UpdateCertStore" + // ImageTypeWifiFirmware - Wifi firmware image type + ImageTypeWifiFirmware ImageType = "WifiFirmware" +) + +// PossibleImageTypeValues returns the possible values for the ImageType const type. +func PossibleImageTypeValues() []ImageType { + return []ImageType{ + ImageTypeApplications, + ImageTypeBaseSystemUpdateManifest, + ImageTypeBootManifest, + ImageTypeCustomerBoardConfig, + ImageTypeCustomerUpdateManifest, + ImageTypeFirmwareUpdateManifest, + ImageTypeFwConfig, + ImageTypeInvalidImageType, + ImageTypeManifestSet, + ImageTypeNormalWorldDtb, + ImageTypeNormalWorldKernel, + ImageTypeNormalWorldLoader, + ImageTypeNwfs, + ImageTypeOneBl, + ImageTypeOther, + ImageTypePlutonRuntime, + ImageTypePolicy, + ImageTypeRecoveryManifest, + ImageTypeRootFs, + ImageTypeSecurityMonitor, + ImageTypeServices, + ImageTypeTrustedKeystore, + ImageTypeUpdateCertStore, + ImageTypeWifiFirmware, + } +} + +// OSFeedType - OS feed type values. +type OSFeedType string + +const ( + // OSFeedTypeRetail - Retail OS feed type. + OSFeedTypeRetail OSFeedType = "Retail" + // OSFeedTypeRetailEval - Retail evaluation OS feed type. + OSFeedTypeRetailEval OSFeedType = "RetailEval" +) + +// PossibleOSFeedTypeValues returns the possible values for the OSFeedType const type. +func PossibleOSFeedTypeValues() []OSFeedType { + return []OSFeedType{ + OSFeedTypeRetail, + OSFeedTypeRetailEval, + } +} + +// 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, + } +} + +// ProvisioningState - Provisioning state of the resource. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - The resource create request has been accepted + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is being updated + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// RegionalDataBoundary - Regional data boundary values. +type RegionalDataBoundary string + +const ( + // RegionalDataBoundaryEU - EU data boundary + RegionalDataBoundaryEU RegionalDataBoundary = "EU" + // RegionalDataBoundaryNone - No data boundary + RegionalDataBoundaryNone RegionalDataBoundary = "None" +) + +// PossibleRegionalDataBoundaryValues returns the possible values for the RegionalDataBoundary const type. +func PossibleRegionalDataBoundaryValues() []RegionalDataBoundary { + return []RegionalDataBoundary{ + RegionalDataBoundaryEU, + RegionalDataBoundaryNone, + } +} + +// UpdatePolicy - Update policy values. +type UpdatePolicy string + +const ( + // UpdatePolicyNo3RdPartyAppUpdates - No update for 3rd party app policy. + UpdatePolicyNo3RdPartyAppUpdates UpdatePolicy = "No3rdPartyAppUpdates" + // UpdatePolicyUpdateAll - Update all policy. + UpdatePolicyUpdateAll UpdatePolicy = "UpdateAll" +) + +// PossibleUpdatePolicyValues returns the possible values for the UpdatePolicy const type. +func PossibleUpdatePolicyValues() []UpdatePolicy { + return []UpdatePolicy{ + UpdatePolicyNo3RdPartyAppUpdates, + UpdatePolicyUpdateAll, + } +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/deployments_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/deployments_client.go new file mode 100644 index 000000000000..e853362d3116 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/deployments_client.go @@ -0,0 +1,391 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" + "strconv" + "strings" +) + +// DeploymentsClient contains the methods for the Deployments group. +// Don't use this type directly, use NewDeploymentsClient() instead. +type DeploymentsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDeploymentsClient creates a new instance of DeploymentsClient 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 NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentsClient, error) { + cl, err := arm.NewClient(moduleName+".DeploymentsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DeploymentsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for +// product or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deploymentName - Deployment name. Use .default for deployment creation and to get the current deployment for the associated +// device group. +// - resource - Resource create parameters. +// - options - DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate +// method. +func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, resource Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DeploymentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product +// or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, resource Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, resource Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product +// or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deploymentName - Deployment name. Use .default for deployment creation and to get the current deployment for the associated +// device group. +// - options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. +func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*runtime.Poller[DeploymentsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DeploymentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or +// device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device +// group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deploymentName - Deployment name. Use .default for deployment creation and to get the current deployment for the associated +// device group. +// - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. +func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (DeploymentsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, options) + if err != nil { + return DeploymentsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeploymentsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (DeploymentsClientGetResponse, error) { + result := DeploymentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Deployment); err != nil { + return DeploymentsClientGetResponse{}, err + } + return result, nil +} + +// NewListByDeviceGroupPager - List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values +// and cannot be used for product or device group name. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - options - DeploymentsClientListByDeviceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByDeviceGroupPager +// method. +func (client *DeploymentsClient) NewListByDeviceGroupPager(resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeploymentsClientListByDeviceGroupOptions) *runtime.Pager[DeploymentsClientListByDeviceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListByDeviceGroupResponse]{ + More: func(page DeploymentsClientListByDeviceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DeploymentsClientListByDeviceGroupResponse) (DeploymentsClientListByDeviceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDeviceGroupCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DeploymentsClientListByDeviceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientListByDeviceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeploymentsClientListByDeviceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByDeviceGroupHandleResponse(resp) + }, + }) +} + +// listByDeviceGroupCreateRequest creates the ListByDeviceGroup request. +func (client *DeploymentsClient) listByDeviceGroupCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeploymentsClientListByDeviceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + reqQP.Set("api-version", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDeviceGroupHandleResponse handles the ListByDeviceGroup response. +func (client *DeploymentsClient) listByDeviceGroupHandleResponse(resp *http.Response) (DeploymentsClientListByDeviceGroupResponse, error) { + result := DeploymentsClientListByDeviceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { + return DeploymentsClientListByDeviceGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/devicegroups_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/devicegroups_client.go new file mode 100644 index 000000000000..d94f5d2a6ae0 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/devicegroups_client.go @@ -0,0 +1,598 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" + "strconv" + "strings" +) + +// DeviceGroupsClient contains the methods for the DeviceGroups group. +// Don't use this type directly, use NewDeviceGroupsClient() instead. +type DeviceGroupsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDeviceGroupsClient creates a new instance of DeviceGroupsClient 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 NewDeviceGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeviceGroupsClient, error) { + cl, err := arm.NewClient(moduleName+".DeviceGroupsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DeviceGroupsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginClaimDevices - Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when +// bulk claiming devices to a catalog only. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - claimDevicesRequest - Bulk claim devices request body. +// - options - DeviceGroupsClientBeginClaimDevicesOptions contains the optional parameters for the DeviceGroupsClient.BeginClaimDevices +// method. +func (client *DeviceGroupsClient) BeginClaimDevices(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, claimDevicesRequest ClaimDevicesRequest, options *DeviceGroupsClientBeginClaimDevicesOptions) (*runtime.Poller[DeviceGroupsClientClaimDevicesResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.claimDevices(ctx, resourceGroupName, catalogName, productName, deviceGroupName, claimDevicesRequest, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeviceGroupsClientClaimDevicesResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DeviceGroupsClientClaimDevicesResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// ClaimDevices - Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when bulk +// claiming devices to a catalog only. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeviceGroupsClient) claimDevices(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, claimDevicesRequest ClaimDevicesRequest, options *DeviceGroupsClientBeginClaimDevicesOptions) (*http.Response, error) { + req, err := client.claimDevicesCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, claimDevicesRequest, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// claimDevicesCreateRequest creates the ClaimDevices request. +func (client *DeviceGroupsClient) claimDevicesCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, claimDevicesRequest ClaimDevicesRequest, options *DeviceGroupsClientBeginClaimDevicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/claimDevices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, claimDevicesRequest) +} + +// CountDevices - Counts devices in device group. '.default' and '.unassigned' are system defined values and cannot be used +// for product or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - options - DeviceGroupsClientCountDevicesOptions contains the optional parameters for the DeviceGroupsClient.CountDevices +// method. +func (client *DeviceGroupsClient) CountDevices(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientCountDevicesOptions) (DeviceGroupsClientCountDevicesResponse, error) { + req, err := client.countDevicesCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + if err != nil { + return DeviceGroupsClientCountDevicesResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeviceGroupsClientCountDevicesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeviceGroupsClientCountDevicesResponse{}, runtime.NewResponseError(resp) + } + return client.countDevicesHandleResponse(resp) +} + +// countDevicesCreateRequest creates the CountDevices request. +func (client *DeviceGroupsClient) countDevicesCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientCountDevicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/countDevices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// countDevicesHandleResponse handles the CountDevices response. +func (client *DeviceGroupsClient) countDevicesHandleResponse(resp *http.Response) (DeviceGroupsClientCountDevicesResponse, error) { + result := DeviceGroupsClientCountDevicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CountDeviceResponse); err != nil { + return DeviceGroupsClientCountDevicesResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for +// product or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - resource - Resource create parameters. +// - options - DeviceGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeviceGroupsClient.BeginCreateOrUpdate +// method. +func (client *DeviceGroupsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, resource DeviceGroup, options *DeviceGroupsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeviceGroupsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, productName, deviceGroupName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeviceGroupsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DeviceGroupsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product +// or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeviceGroupsClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, resource DeviceGroup, options *DeviceGroupsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DeviceGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, resource DeviceGroup, options *DeviceGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product +// or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - options - DeviceGroupsClientBeginDeleteOptions contains the optional parameters for the DeviceGroupsClient.BeginDelete +// method. +func (client *DeviceGroupsClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientBeginDeleteOptions) (*runtime.Poller[DeviceGroupsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeviceGroupsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DeviceGroupsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or +// device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeviceGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DeviceGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device +// group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - options - DeviceGroupsClientGetOptions contains the optional parameters for the DeviceGroupsClient.Get method. +func (client *DeviceGroupsClient) Get(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientGetOptions) (DeviceGroupsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + if err != nil { + return DeviceGroupsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeviceGroupsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeviceGroupsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DeviceGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DeviceGroupsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DeviceGroupsClient) getHandleResponse(resp *http.Response) (DeviceGroupsClientGetResponse, error) { + result := DeviceGroupsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceGroup); err != nil { + return DeviceGroupsClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and +// cannot be used for product name. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - options - DeviceGroupsClientListByProductOptions contains the optional parameters for the DeviceGroupsClient.NewListByProductPager +// method. +func (client *DeviceGroupsClient) NewListByProductPager(resourceGroupName string, catalogName string, productName string, options *DeviceGroupsClientListByProductOptions) *runtime.Pager[DeviceGroupsClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[DeviceGroupsClientListByProductResponse]{ + More: func(page DeviceGroupsClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DeviceGroupsClientListByProductResponse) (DeviceGroupsClientListByProductResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByProductCreateRequest(ctx, resourceGroupName, catalogName, productName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DeviceGroupsClientListByProductResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeviceGroupsClientListByProductResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeviceGroupsClientListByProductResponse{}, runtime.NewResponseError(resp) + } + return client.listByProductHandleResponse(resp) + }, + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *DeviceGroupsClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *DeviceGroupsClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + reqQP.Set("api-version", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *DeviceGroupsClient) listByProductHandleResponse(resp *http.Response) (DeviceGroupsClientListByProductResponse, error) { + result := DeviceGroupsClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceGroupListResult); err != nil { + return DeviceGroupsClientListByProductResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product +// or device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - properties - The resource properties to be updated. +// - options - DeviceGroupsClientBeginUpdateOptions contains the optional parameters for the DeviceGroupsClient.BeginUpdate +// method. +func (client *DeviceGroupsClient) BeginUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, properties DeviceGroupUpdate, options *DeviceGroupsClientBeginUpdateOptions) (*runtime.Poller[DeviceGroupsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, catalogName, productName, deviceGroupName, properties, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeviceGroupsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DeviceGroupsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or +// device group name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DeviceGroupsClient) update(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, properties DeviceGroupUpdate, options *DeviceGroupsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, properties, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DeviceGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, properties DeviceGroupUpdate, options *DeviceGroupsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/devices_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/devices_client.go new file mode 100644 index 000000000000..72d0599b2a4e --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/devices_client.go @@ -0,0 +1,544 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" +) + +// DevicesClient contains the methods for the Devices group. +// Don't use this type directly, use NewDevicesClient() instead. +type DevicesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDevicesClient creates a new instance of DevicesClient 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 NewDevicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DevicesClient, error) { + cl, err := arm.NewClient(moduleName+".DevicesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DevicesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Device. Use '.unassigned' or '.default' for the device group and product names to claim +// a device to the catalog only. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deviceName - Device name +// - resource - Resource create parameters. +// - options - DevicesClientBeginCreateOrUpdateOptions contains the optional parameters for the DevicesClient.BeginCreateOrUpdate +// method. +func (client *DevicesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, resource Device, options *DevicesClientBeginCreateOrUpdateOptions) (*runtime.Poller[DevicesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DevicesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevicesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Device. Use '.unassigned' or '.default' for the device group and product names to claim a device +// to the catalog only. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DevicesClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, resource Device, options *DevicesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DevicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, resource Device, options *DevicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deviceName == "" { + return nil, errors.New("parameter deviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Device +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deviceName - Device name +// - options - DevicesClientBeginDeleteOptions contains the optional parameters for the DevicesClient.BeginDelete method. +func (client *DevicesClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, options *DevicesClientBeginDeleteOptions) (*runtime.Poller[DevicesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DevicesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DevicesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Device +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DevicesClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, options *DevicesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DevicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, options *DevicesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deviceName == "" { + return nil, errors.New("parameter deviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginGenerateCapabilityImage - Generates the capability image for the device. Use '.unassigned' or '.default' for the device +// group and product names to generate the image for a device that does not belong to a specific device group +// and product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deviceName - Device name +// - generateDeviceCapabilityRequest - Generate capability image request body. +// - options - DevicesClientBeginGenerateCapabilityImageOptions contains the optional parameters for the DevicesClient.BeginGenerateCapabilityImage +// method. +func (client *DevicesClient) BeginGenerateCapabilityImage(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, generateDeviceCapabilityRequest GenerateCapabilityImageRequest, options *DevicesClientBeginGenerateCapabilityImageOptions) (*runtime.Poller[DevicesClientGenerateCapabilityImageResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateCapabilityImage(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, generateDeviceCapabilityRequest, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DevicesClientGenerateCapabilityImageResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DevicesClientGenerateCapabilityImageResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateCapabilityImage - Generates the capability image for the device. Use '.unassigned' or '.default' for the device +// group and product names to generate the image for a device that does not belong to a specific device group +// and product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DevicesClient) generateCapabilityImage(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, generateDeviceCapabilityRequest GenerateCapabilityImageRequest, options *DevicesClientBeginGenerateCapabilityImageOptions) (*http.Response, error) { + req, err := client.generateCapabilityImageCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, generateDeviceCapabilityRequest, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// generateCapabilityImageCreateRequest creates the GenerateCapabilityImage request. +func (client *DevicesClient) generateCapabilityImageCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, generateDeviceCapabilityRequest GenerateCapabilityImageRequest, options *DevicesClientBeginGenerateCapabilityImageOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}/generateCapabilityImage" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deviceName == "" { + return nil, errors.New("parameter deviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, generateDeviceCapabilityRequest) +} + +// Get - Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong +// to a device group and product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deviceName - Device name +// - options - DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method. +func (client *DevicesClient) Get(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, options *DevicesClientGetOptions) (DevicesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, options) + if err != nil { + return DevicesClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DevicesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevicesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DevicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, options *DevicesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deviceName == "" { + return nil, errors.New("parameter deviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DevicesClient) getHandleResponse(resp *http.Response) (DevicesClientGetResponse, error) { + result := DevicesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Device); err != nil { + return DevicesClientGetResponse{}, err + } + return result, nil +} + +// NewListByDeviceGroupPager - List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values +// and cannot be used for product or device group name. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - options - DevicesClientListByDeviceGroupOptions contains the optional parameters for the DevicesClient.NewListByDeviceGroupPager +// method. +func (client *DevicesClient) NewListByDeviceGroupPager(resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DevicesClientListByDeviceGroupOptions) *runtime.Pager[DevicesClientListByDeviceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DevicesClientListByDeviceGroupResponse]{ + More: func(page DevicesClientListByDeviceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DevicesClientListByDeviceGroupResponse) (DevicesClientListByDeviceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDeviceGroupCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DevicesClientListByDeviceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DevicesClientListByDeviceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevicesClientListByDeviceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByDeviceGroupHandleResponse(resp) + }, + }) +} + +// listByDeviceGroupCreateRequest creates the ListByDeviceGroup request. +func (client *DevicesClient) listByDeviceGroupCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, options *DevicesClientListByDeviceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDeviceGroupHandleResponse handles the ListByDeviceGroup response. +func (client *DevicesClient) listByDeviceGroupHandleResponse(resp *http.Response) (DevicesClientListByDeviceGroupResponse, error) { + result := DevicesClientListByDeviceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceListResult); err != nil { + return DevicesClientListByDeviceGroupResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device +// to the catalog level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - deviceGroupName - Name of device group. +// - deviceName - Device name +// - properties - The resource properties to be updated. +// - options - DevicesClientBeginUpdateOptions contains the optional parameters for the DevicesClient.BeginUpdate method. +func (client *DevicesClient) BeginUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, properties DeviceUpdate, options *DevicesClientBeginUpdateOptions) (*runtime.Poller[DevicesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, properties, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DevicesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[DevicesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device to the +// catalog level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *DevicesClient) update(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, properties DeviceUpdate, options *DevicesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, properties, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DevicesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, deviceGroupName string, deviceName string, properties DeviceUpdate, options *DevicesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + if deviceGroupName == "" { + return nil, errors.New("parameter deviceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceGroupName}", url.PathEscape(deviceGroupName)) + if deviceName == "" { + return nil, errors.New("parameter deviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/go.mod b/sdk/resourcemanager/azuresphere/armazuresphere/go.mod new file mode 100644 index 000000000000..9cf08d6ed375 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuresphere/armazuresphere + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/go.sum b/sdk/resourcemanager/azuresphere/armazuresphere/go.sum new file mode 100644 index 000000000000..f54c298864a1 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/images_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/images_client.go new file mode 100644 index 000000000000..72b5e29ea176 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/images_client.go @@ -0,0 +1,342 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" + "strconv" + "strings" +) + +// ImagesClient contains the methods for the Images group. +// Don't use this type directly, use NewImagesClient() instead. +type ImagesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewImagesClient creates a new instance of ImagesClient 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 NewImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImagesClient, error) { + cl, err := arm.NewClient(moduleName+".ImagesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ImagesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Image +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - imageName - Image name. Use .default for image creation. +// - resource - Resource create parameters. +// - options - ImagesClientBeginCreateOrUpdateOptions contains the optional parameters for the ImagesClient.BeginCreateOrUpdate +// method. +func (client *ImagesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, imageName string, resource Image, options *ImagesClientBeginCreateOrUpdateOptions) (*runtime.Poller[ImagesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, imageName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImagesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ImagesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Image +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *ImagesClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, imageName string, resource Image, options *ImagesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, imageName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ImagesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, imageName string, resource Image, options *ImagesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Image +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - imageName - Image name. Use .default for image creation. +// - options - ImagesClientBeginDeleteOptions contains the optional parameters for the ImagesClient.BeginDelete method. +func (client *ImagesClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, imageName string, options *ImagesClientBeginDeleteOptions) (*runtime.Poller[ImagesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, imageName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImagesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[ImagesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Image +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *ImagesClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, imageName string, options *ImagesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, imageName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ImagesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, imageName string, options *ImagesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Image +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - imageName - Image name. Use .default for image creation. +// - options - ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. +func (client *ImagesClient) Get(ctx context.Context, resourceGroupName string, catalogName string, imageName string, options *ImagesClientGetOptions) (ImagesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, imageName, options) + if err != nil { + return ImagesClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ImagesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImagesClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, imageName string, options *ImagesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImagesClient) getHandleResponse(resp *http.Response) (ImagesClientGetResponse, error) { + result := ImagesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Image); err != nil { + return ImagesClientGetResponse{}, err + } + return result, nil +} + +// NewListByCatalogPager - List Image resources by Catalog +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - ImagesClientListByCatalogOptions contains the optional parameters for the ImagesClient.NewListByCatalogPager +// method. +func (client *ImagesClient) NewListByCatalogPager(resourceGroupName string, catalogName string, options *ImagesClientListByCatalogOptions) *runtime.Pager[ImagesClientListByCatalogResponse] { + return runtime.NewPager(runtime.PagingHandler[ImagesClientListByCatalogResponse]{ + More: func(page ImagesClientListByCatalogResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ImagesClientListByCatalogResponse) (ImagesClientListByCatalogResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByCatalogCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ImagesClientListByCatalogResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ImagesClientListByCatalogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesClientListByCatalogResponse{}, runtime.NewResponseError(resp) + } + return client.listByCatalogHandleResponse(resp) + }, + }) +} + +// listByCatalogCreateRequest creates the ListByCatalog request. +func (client *ImagesClient) listByCatalogCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *ImagesClientListByCatalogOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("$maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + reqQP.Set("api-version", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCatalogHandleResponse handles the ListByCatalog response. +func (client *ImagesClient) listByCatalogHandleResponse(resp *http.Response) (ImagesClientListByCatalogResponse, error) { + result := ImagesClientListByCatalogResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ImageListResult); err != nil { + return ImagesClientListByCatalogResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/models.go b/sdk/resourcemanager/azuresphere/armazuresphere/models.go new file mode 100644 index 000000000000..99be9860039c --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/models.go @@ -0,0 +1,881 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +import "time" + +// Catalog - An Azure Sphere catalog +type Catalog struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *CatalogProperties + + // 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 +} + +// CatalogListResult - The response of a Catalog list operation. +type CatalogListResult struct { + // REQUIRED; The Catalog items on this page + Value []*Catalog + + // The link to the next page of items + NextLink *string +} + +// CatalogProperties - Catalog properties +type CatalogProperties struct { + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// CatalogUpdate - The type used for update operations of the Catalog. +type CatalogUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// CatalogsClientBeginCreateOrUpdateOptions contains the optional parameters for the CatalogsClient.BeginCreateOrUpdate method. +type CatalogsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientBeginDeleteOptions contains the optional parameters for the CatalogsClient.BeginDelete method. +type CatalogsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientCountDevicesOptions contains the optional parameters for the CatalogsClient.CountDevices method. +type CatalogsClientCountDevicesOptions struct { + // placeholder for future optional parameters +} + +// CatalogsClientGetOptions contains the optional parameters for the CatalogsClient.Get method. +type CatalogsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CatalogsClientListByResourceGroupOptions contains the optional parameters for the CatalogsClient.NewListByResourceGroupPager +// method. +type CatalogsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CatalogsClientListBySubscriptionOptions contains the optional parameters for the CatalogsClient.NewListBySubscriptionPager +// method. +type CatalogsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// CatalogsClientListDeploymentsOptions contains the optional parameters for the CatalogsClient.NewListDeploymentsPager method. +type CatalogsClientListDeploymentsOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// CatalogsClientListDeviceGroupsOptions contains the optional parameters for the CatalogsClient.NewListDeviceGroupsPager +// method. +type CatalogsClientListDeviceGroupsOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// CatalogsClientListDeviceInsightsOptions contains the optional parameters for the CatalogsClient.NewListDeviceInsightsPager +// method. +type CatalogsClientListDeviceInsightsOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// CatalogsClientListDevicesOptions contains the optional parameters for the CatalogsClient.NewListDevicesPager method. +type CatalogsClientListDevicesOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// CatalogsClientUpdateOptions contains the optional parameters for the CatalogsClient.Update method. +type CatalogsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Certificate - An certificate resource belonging to a catalog resource. +type Certificate struct { + // The resource-specific properties for this resource. + Properties *CertificateProperties + + // 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 +} + +// CertificateChainResponse - The certificate chain response. +type CertificateChainResponse struct { + // READ-ONLY; The certificate chain. + CertificateChain *string +} + +// CertificateListResult - The response of a Certificate list operation. +type CertificateListResult struct { + // REQUIRED; The Certificate items on this page + Value []*Certificate + + // The link to the next page of items + NextLink *string +} + +// CertificateProperties - The properties of certificate +type CertificateProperties struct { + // READ-ONLY; The certificate as a UTF-8 encoded base 64 string. + Certificate *string + + // READ-ONLY; The certificate expiry date. + ExpiryUTC *time.Time + + // READ-ONLY; The certificate not before date. + NotBeforeUTC *time.Time + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The certificate status. + Status *CertificateStatus + + // READ-ONLY; The certificate subject. + Subject *string + + // READ-ONLY; The certificate thumbprint. + Thumbprint *string +} + +// CertificatesClientGetOptions contains the optional parameters for the CertificatesClient.Get method. +type CertificatesClientGetOptions struct { + // placeholder for future optional parameters +} + +// CertificatesClientListByCatalogOptions contains the optional parameters for the CertificatesClient.NewListByCatalogPager +// method. +type CertificatesClientListByCatalogOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// CertificatesClientRetrieveCertChainOptions contains the optional parameters for the CertificatesClient.RetrieveCertChain +// method. +type CertificatesClientRetrieveCertChainOptions struct { + // placeholder for future optional parameters +} + +// CertificatesClientRetrieveProofOfPossessionNonceOptions contains the optional parameters for the CertificatesClient.RetrieveProofOfPossessionNonce +// method. +type CertificatesClientRetrieveProofOfPossessionNonceOptions struct { + // placeholder for future optional parameters +} + +// ClaimDevicesRequest - Request to the action call to bulk claim devices. +type ClaimDevicesRequest struct { + // REQUIRED; Device identifiers of the devices to be claimed. + DeviceIdentifiers []*string +} + +// CountDeviceResponse - Response to the action call for count devices in a catalog. +type CountDeviceResponse struct { + // REQUIRED; Number of children resources in parent resource. + Value *int32 +} + +// Deployment - An deployment resource belonging to a device group resource. +type Deployment struct { + // The resource-specific properties for this resource. + Properties *DeploymentProperties + + // 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 +} + +// DeploymentListResult - The response of a Deployment list operation. +type DeploymentListResult struct { + // REQUIRED; The Deployment items on this page + Value []*Deployment + + // The link to the next page of items + NextLink *string +} + +// DeploymentProperties - The properties of deployment +type DeploymentProperties struct { + // Images deployed + DeployedImages []*Image + + // Deployment ID + DeploymentID *string + + // READ-ONLY; Deployment date UTC + DeploymentDateUTC *time.Time + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate +// method. +type DeploymentsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. +type DeploymentsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. +type DeploymentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientListByDeviceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByDeviceGroupPager +// method. +type DeploymentsClientListByDeviceGroupOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// Device - An device resource belonging to a device group resource. +type Device struct { + // The resource-specific properties for this resource. + Properties *DeviceProperties + + // 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 +} + +// DeviceGroup - An device group resource belonging to a product resource. +type DeviceGroup struct { + // The resource-specific properties for this resource. + Properties *DeviceGroupProperties + + // 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 +} + +// DeviceGroupListResult - The response of a DeviceGroup list operation. +type DeviceGroupListResult struct { + // REQUIRED; The DeviceGroup items on this page + Value []*DeviceGroup + + // The link to the next page of items + NextLink *string +} + +// DeviceGroupProperties - The properties of deviceGroup +type DeviceGroupProperties struct { + // Flag to define if the user allows for crash dump collection. + AllowCrashDumpsCollection *AllowCrashDumpCollection + + // Description of the device group. + Description *string + + // Operating system feed type of the device group. + OSFeedType *OSFeedType + + // Regional data boundary for the device group. + RegionalDataBoundary *RegionalDataBoundary + + // Update policy of the device group. + UpdatePolicy *UpdatePolicy + + // READ-ONLY; Deployment status for the device group. + HasDeployment *bool + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// DeviceGroupUpdate - The type used for update operations of the DeviceGroup. +type DeviceGroupUpdate struct { + // The updatable properties of the DeviceGroup. + Properties *DeviceGroupUpdateProperties +} + +// DeviceGroupUpdateProperties - The updatable properties of the DeviceGroup. +type DeviceGroupUpdateProperties struct { + // Flag to define if the user allows for crash dump collection. + AllowCrashDumpsCollection *AllowCrashDumpCollection + + // Description of the device group. + Description *string + + // Operating system feed type of the device group. + OSFeedType *OSFeedType + + // Regional data boundary for the device group. + RegionalDataBoundary *RegionalDataBoundary + + // Update policy of the device group. + UpdatePolicy *UpdatePolicy +} + +// DeviceGroupsClientBeginClaimDevicesOptions contains the optional parameters for the DeviceGroupsClient.BeginClaimDevices +// method. +type DeviceGroupsClientBeginClaimDevicesOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeviceGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeviceGroupsClient.BeginCreateOrUpdate +// method. +type DeviceGroupsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeviceGroupsClientBeginDeleteOptions contains the optional parameters for the DeviceGroupsClient.BeginDelete method. +type DeviceGroupsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeviceGroupsClientBeginUpdateOptions contains the optional parameters for the DeviceGroupsClient.BeginUpdate method. +type DeviceGroupsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeviceGroupsClientCountDevicesOptions contains the optional parameters for the DeviceGroupsClient.CountDevices method. +type DeviceGroupsClientCountDevicesOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientGetOptions contains the optional parameters for the DeviceGroupsClient.Get method. +type DeviceGroupsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientListByProductOptions contains the optional parameters for the DeviceGroupsClient.NewListByProductPager +// method. +type DeviceGroupsClientListByProductOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// DeviceInsight - Device insight report. +type DeviceInsight struct { + // REQUIRED; Event description + Description *string + + // REQUIRED; Device ID + DeviceID *string + + // REQUIRED; Event end timestamp + EndTimestampUTC *time.Time + + // REQUIRED; Event category + EventCategory *string + + // REQUIRED; Event class + EventClass *string + + // REQUIRED; Event count + EventCount *int32 + + // REQUIRED; Event type + EventType *string + + // REQUIRED; Event start timestamp + StartTimestampUTC *time.Time +} + +// DeviceListResult - The response of a Device list operation. +type DeviceListResult struct { + // REQUIRED; The Device items on this page + Value []*Device + + // The link to the next page of items + NextLink *string +} + +// DeviceProperties - The properties of device +type DeviceProperties struct { + // Device ID + DeviceID *string + + // READ-ONLY; SKU of the chip + ChipSKU *string + + // READ-ONLY; OS version available for installation when update requested + LastAvailableOsVersion *string + + // READ-ONLY; OS version running on device when update requested + LastInstalledOsVersion *string + + // READ-ONLY; Time when update requested and new OS version available + LastOsUpdateUTC *time.Time + + // READ-ONLY; Time when update was last requested + LastUpdateRequestUTC *time.Time + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// DeviceUpdate - The type used for update operations of the Device. +type DeviceUpdate struct { + // The updatable properties of the Device. + Properties *DeviceUpdateProperties +} + +// DeviceUpdateProperties - The updatable properties of the Device. +type DeviceUpdateProperties struct { + // Device group id + DeviceGroupID *string +} + +// DevicesClientBeginCreateOrUpdateOptions contains the optional parameters for the DevicesClient.BeginCreateOrUpdate method. +type DevicesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevicesClientBeginDeleteOptions contains the optional parameters for the DevicesClient.BeginDelete method. +type DevicesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevicesClientBeginGenerateCapabilityImageOptions contains the optional parameters for the DevicesClient.BeginGenerateCapabilityImage +// method. +type DevicesClientBeginGenerateCapabilityImageOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevicesClientBeginUpdateOptions contains the optional parameters for the DevicesClient.BeginUpdate method. +type DevicesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method. +type DevicesClientGetOptions struct { + // placeholder for future optional parameters +} + +// DevicesClientListByDeviceGroupOptions contains the optional parameters for the DevicesClient.NewListByDeviceGroupPager +// method. +type DevicesClientListByDeviceGroupOptions struct { + // placeholder for future optional parameters +} + +// GenerateCapabilityImageRequest - Request of the action to create a signed device capability image +type GenerateCapabilityImageRequest struct { + // REQUIRED; List of capabilities to create + Capabilities []*CapabilityType +} + +// Image - An image resource belonging to a catalog resource. +type Image struct { + // The resource-specific properties for this resource. + Properties *ImageProperties + + // 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 +} + +// ImageListResult - The response of a Image list operation. +type ImageListResult struct { + // REQUIRED; The Image items on this page + Value []*Image + + // The link to the next page of items + NextLink *string +} + +// ImageProperties - The properties of image +type ImageProperties struct { + // Image as a UTF-8 encoded base 64 string on image create. This field contains the image URI on image reads. + Image *string + + // Image ID + ImageID *string + + // Regional data boundary for an image + RegionalDataBoundary *RegionalDataBoundary + + // READ-ONLY; The image component id. + ComponentID *string + + // READ-ONLY; The image description. + Description *string + + // READ-ONLY; Image name + ImageName *string + + // READ-ONLY; The image type. + ImageType *ImageType + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; Location the image + URI *string +} + +// ImagesClientBeginCreateOrUpdateOptions contains the optional parameters for the ImagesClient.BeginCreateOrUpdate method. +type ImagesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ImagesClientBeginDeleteOptions contains the optional parameters for the ImagesClient.BeginDelete method. +type ImagesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. +type ImagesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ImagesClientListByCatalogOptions contains the optional parameters for the ImagesClient.NewListByCatalogPager method. +type ImagesClientListByCatalogOptions struct { + // Filter the result list using the given expression + Filter *string + // The maximum number of result items per page. + Maxpagesize *int32 + // The number of result items to skip. + Skip *int32 + // The number of result items to return. + Top *int32 +} + +// ListDeviceGroupsRequest - Request of the action to list device groups for a catalog. +type ListDeviceGroupsRequest struct { + // Device Group name. + DeviceGroupName *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 +} + +// PagedDeviceInsight - Paged collection of DeviceInsight items +type PagedDeviceInsight struct { + // REQUIRED; The DeviceInsight items on this page + Value []*DeviceInsight + + // The link to the next page of items + NextLink *string +} + +// Product - An product resource belonging to a catalog resource. +type Product struct { + // The resource-specific properties for this resource. + Properties *ProductProperties + + // 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 +} + +// ProductListResult - The response of a Product list operation. +type ProductListResult struct { + // REQUIRED; The Product items on this page + Value []*Product + + // The link to the next page of items + NextLink *string +} + +// ProductProperties - The properties of product +type ProductProperties struct { + // REQUIRED; Description of the product + Description *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// ProductUpdate - The type used for update operations of the Product. +type ProductUpdate struct { + // The updatable properties of the Product. + Properties *ProductUpdateProperties +} + +// ProductUpdateProperties - The updatable properties of the Product. +type ProductUpdateProperties struct { + // Description of the product + Description *string +} + +// ProductsClientBeginCreateOrUpdateOptions contains the optional parameters for the ProductsClient.BeginCreateOrUpdate method. +type ProductsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProductsClientBeginDeleteOptions contains the optional parameters for the ProductsClient.BeginDelete method. +type ProductsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProductsClientBeginUpdateOptions contains the optional parameters for the ProductsClient.BeginUpdate method. +type ProductsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProductsClientCountDevicesOptions contains the optional parameters for the ProductsClient.CountDevices method. +type ProductsClientCountDevicesOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientGenerateDefaultDeviceGroupsOptions contains the optional parameters for the ProductsClient.NewGenerateDefaultDeviceGroupsPager +// method. +type ProductsClientGenerateDefaultDeviceGroupsOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. +type ProductsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientListByCatalogOptions contains the optional parameters for the ProductsClient.NewListByCatalogPager method. +type ProductsClientListByCatalogOptions struct { + // placeholder for future optional parameters +} + +// ProofOfPossessionNonceRequest - Request for the proof of possession nonce +type ProofOfPossessionNonceRequest struct { + // REQUIRED; The proof of possession nonce + ProofOfPossessionNonce *string +} + +// ProofOfPossessionNonceResponse - Result of the action to generate a proof of possession nonce +type ProofOfPossessionNonceResponse struct { + // READ-ONLY; The certificate as a UTF-8 encoded base 64 string. + Certificate *string + + // READ-ONLY; The certificate expiry date. + ExpiryUTC *time.Time + + // READ-ONLY; The certificate not before date. + NotBeforeUTC *time.Time + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The certificate status. + Status *CertificateStatus + + // READ-ONLY; The certificate subject. + Subject *string + + // READ-ONLY; The certificate thumbprint. + Thumbprint *string +} + +// SignedCapabilityImageResponse - Signed device capability image response +type SignedCapabilityImageResponse struct { + // READ-ONLY; The signed device capability image as a UTF-8 encoded base 64 string. + Image *string +} + +// 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 +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/models_serde.go b/sdk/resourcemanager/azuresphere/armazuresphere/models_serde.go new file mode 100644 index 000000000000..6094b00fe5f1 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/models_serde.go @@ -0,0 +1,1571 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Catalog. +func (c Catalog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Catalog. +func (c *Catalog) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CatalogListResult. +func (c CatalogListResult) 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 CatalogListResult. +func (c *CatalogListResult) 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 CatalogProperties. +func (c CatalogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", c.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogProperties. +func (c *CatalogProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + 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 CatalogUpdate. +func (c CatalogUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogUpdate. +func (c *CatalogUpdate) 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 "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 Certificate. +func (c Certificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Certificate. +func (c *Certificate) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CertificateChainResponse. +func (c CertificateChainResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificateChain", c.CertificateChain) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateChainResponse. +func (c *CertificateChainResponse) 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 "certificateChain": + err = unpopulate(val, "CertificateChain", &c.CertificateChain) + 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 CertificateListResult. +func (c CertificateListResult) 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 CertificateListResult. +func (c *CertificateListResult) 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 CertificateProperties. +func (c CertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificate", c.Certificate) + populateTimeRFC3339(objectMap, "expiryUtc", c.ExpiryUTC) + populateTimeRFC3339(objectMap, "notBeforeUtc", c.NotBeforeUTC) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "status", c.Status) + populate(objectMap, "subject", c.Subject) + populate(objectMap, "thumbprint", c.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateProperties. +func (c *CertificateProperties) 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 "certificate": + err = unpopulate(val, "Certificate", &c.Certificate) + delete(rawMsg, key) + case "expiryUtc": + err = unpopulateTimeRFC3339(val, "ExpiryUTC", &c.ExpiryUTC) + delete(rawMsg, key) + case "notBeforeUtc": + err = unpopulateTimeRFC3339(val, "NotBeforeUTC", &c.NotBeforeUTC) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &c.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &c.Thumbprint) + 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 ClaimDevicesRequest. +func (c ClaimDevicesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceIdentifiers", c.DeviceIdentifiers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClaimDevicesRequest. +func (c *ClaimDevicesRequest) 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 "deviceIdentifiers": + err = unpopulate(val, "DeviceIdentifiers", &c.DeviceIdentifiers) + 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 CountDeviceResponse. +func (c CountDeviceResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CountDeviceResponse. +func (c *CountDeviceResponse) 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 "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 Deployment. +func (d Deployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Deployment. +func (d *Deployment) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentListResult. +func (d DeploymentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentListResult. +func (d *DeploymentListResult) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. +func (d DeploymentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deployedImages", d.DeployedImages) + populateTimeRFC3339(objectMap, "deploymentDateUtc", d.DeploymentDateUTC) + populate(objectMap, "deploymentId", d.DeploymentID) + populate(objectMap, "provisioningState", d.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. +func (d *DeploymentProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deployedImages": + err = unpopulate(val, "DeployedImages", &d.DeployedImages) + delete(rawMsg, key) + case "deploymentDateUtc": + err = unpopulateTimeRFC3339(val, "DeploymentDateUTC", &d.DeploymentDateUTC) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &d.DeploymentID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Device. +func (d Device) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Device. +func (d *Device) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceGroup. +func (d DeviceGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceGroup. +func (d *DeviceGroup) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceGroupListResult. +func (d DeviceGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceGroupListResult. +func (d *DeviceGroupListResult) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceGroupProperties. +func (d DeviceGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowCrashDumpsCollection", d.AllowCrashDumpsCollection) + populate(objectMap, "description", d.Description) + populate(objectMap, "hasDeployment", d.HasDeployment) + populate(objectMap, "osFeedType", d.OSFeedType) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "regionalDataBoundary", d.RegionalDataBoundary) + populate(objectMap, "updatePolicy", d.UpdatePolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceGroupProperties. +func (d *DeviceGroupProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowCrashDumpsCollection": + err = unpopulate(val, "AllowCrashDumpsCollection", &d.AllowCrashDumpsCollection) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "hasDeployment": + err = unpopulate(val, "HasDeployment", &d.HasDeployment) + delete(rawMsg, key) + case "osFeedType": + err = unpopulate(val, "OSFeedType", &d.OSFeedType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "regionalDataBoundary": + err = unpopulate(val, "RegionalDataBoundary", &d.RegionalDataBoundary) + delete(rawMsg, key) + case "updatePolicy": + err = unpopulate(val, "UpdatePolicy", &d.UpdatePolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceGroupUpdate. +func (d DeviceGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceGroupUpdate. +func (d *DeviceGroupUpdate) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceGroupUpdateProperties. +func (d DeviceGroupUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowCrashDumpsCollection", d.AllowCrashDumpsCollection) + populate(objectMap, "description", d.Description) + populate(objectMap, "osFeedType", d.OSFeedType) + populate(objectMap, "regionalDataBoundary", d.RegionalDataBoundary) + populate(objectMap, "updatePolicy", d.UpdatePolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceGroupUpdateProperties. +func (d *DeviceGroupUpdateProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowCrashDumpsCollection": + err = unpopulate(val, "AllowCrashDumpsCollection", &d.AllowCrashDumpsCollection) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "osFeedType": + err = unpopulate(val, "OSFeedType", &d.OSFeedType) + delete(rawMsg, key) + case "regionalDataBoundary": + err = unpopulate(val, "RegionalDataBoundary", &d.RegionalDataBoundary) + delete(rawMsg, key) + case "updatePolicy": + err = unpopulate(val, "UpdatePolicy", &d.UpdatePolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceInsight. +func (d DeviceInsight) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", d.Description) + populate(objectMap, "deviceId", d.DeviceID) + populateTimeRFC3339(objectMap, "endTimestampUtc", d.EndTimestampUTC) + populate(objectMap, "eventCategory", d.EventCategory) + populate(objectMap, "eventClass", d.EventClass) + populate(objectMap, "eventCount", d.EventCount) + populate(objectMap, "eventType", d.EventType) + populateTimeRFC3339(objectMap, "startTimestampUtc", d.StartTimestampUTC) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceInsight. +func (d *DeviceInsight) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &d.DeviceID) + delete(rawMsg, key) + case "endTimestampUtc": + err = unpopulateTimeRFC3339(val, "EndTimestampUTC", &d.EndTimestampUTC) + delete(rawMsg, key) + case "eventCategory": + err = unpopulate(val, "EventCategory", &d.EventCategory) + delete(rawMsg, key) + case "eventClass": + err = unpopulate(val, "EventClass", &d.EventClass) + delete(rawMsg, key) + case "eventCount": + err = unpopulate(val, "EventCount", &d.EventCount) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &d.EventType) + delete(rawMsg, key) + case "startTimestampUtc": + err = unpopulateTimeRFC3339(val, "StartTimestampUTC", &d.StartTimestampUTC) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceListResult. +func (d DeviceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceListResult. +func (d *DeviceListResult) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceProperties. +func (d DeviceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "chipSku", d.ChipSKU) + populate(objectMap, "deviceId", d.DeviceID) + populate(objectMap, "lastAvailableOsVersion", d.LastAvailableOsVersion) + populate(objectMap, "lastInstalledOsVersion", d.LastInstalledOsVersion) + populateTimeRFC3339(objectMap, "lastOsUpdateUtc", d.LastOsUpdateUTC) + populateTimeRFC3339(objectMap, "lastUpdateRequestUtc", d.LastUpdateRequestUTC) + populate(objectMap, "provisioningState", d.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceProperties. +func (d *DeviceProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "chipSku": + err = unpopulate(val, "ChipSKU", &d.ChipSKU) + delete(rawMsg, key) + case "deviceId": + err = unpopulate(val, "DeviceID", &d.DeviceID) + delete(rawMsg, key) + case "lastAvailableOsVersion": + err = unpopulate(val, "LastAvailableOsVersion", &d.LastAvailableOsVersion) + delete(rawMsg, key) + case "lastInstalledOsVersion": + err = unpopulate(val, "LastInstalledOsVersion", &d.LastInstalledOsVersion) + delete(rawMsg, key) + case "lastOsUpdateUtc": + err = unpopulateTimeRFC3339(val, "LastOsUpdateUTC", &d.LastOsUpdateUTC) + delete(rawMsg, key) + case "lastUpdateRequestUtc": + err = unpopulateTimeRFC3339(val, "LastUpdateRequestUTC", &d.LastUpdateRequestUTC) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceUpdate. +func (d DeviceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceUpdate. +func (d *DeviceUpdate) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeviceUpdateProperties. +func (d DeviceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceGroupId", d.DeviceGroupID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceUpdateProperties. +func (d *DeviceUpdateProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceGroupId": + err = unpopulate(val, "DeviceGroupID", &d.DeviceGroupID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateCapabilityImageRequest. +func (g GenerateCapabilityImageRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capabilities", g.Capabilities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateCapabilityImageRequest. +func (g *GenerateCapabilityImageRequest) 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 "capabilities": + err = unpopulate(val, "Capabilities", &g.Capabilities) + 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 Image. +func (i Image) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Image. +func (i *Image) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageListResult. +func (i ImageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageListResult. +func (i *ImageListResult) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageProperties. +func (i ImageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "componentId", i.ComponentID) + populate(objectMap, "description", i.Description) + populate(objectMap, "image", i.Image) + populate(objectMap, "imageId", i.ImageID) + populate(objectMap, "imageName", i.ImageName) + populate(objectMap, "imageType", i.ImageType) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "regionalDataBoundary", i.RegionalDataBoundary) + populate(objectMap, "uri", i.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageProperties. +func (i *ImageProperties) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "componentId": + err = unpopulate(val, "ComponentID", &i.ComponentID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &i.Description) + delete(rawMsg, key) + case "image": + err = unpopulate(val, "Image", &i.Image) + delete(rawMsg, key) + case "imageId": + err = unpopulate(val, "ImageID", &i.ImageID) + delete(rawMsg, key) + case "imageName": + err = unpopulate(val, "ImageName", &i.ImageName) + delete(rawMsg, key) + case "imageType": + err = unpopulate(val, "ImageType", &i.ImageType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "regionalDataBoundary": + err = unpopulate(val, "RegionalDataBoundary", &i.RegionalDataBoundary) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &i.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListDeviceGroupsRequest. +func (l ListDeviceGroupsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceGroupName", l.DeviceGroupName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListDeviceGroupsRequest. +func (l *ListDeviceGroupsRequest) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceGroupName": + err = unpopulate(val, "DeviceGroupName", &l.DeviceGroupName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, 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 PagedDeviceInsight. +func (p PagedDeviceInsight) 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 PagedDeviceInsight. +func (p *PagedDeviceInsight) 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 Product. +func (p Product) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Product. +func (p *Product) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + 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 ProductListResult. +func (p ProductListResult) 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 ProductListResult. +func (p *ProductListResult) 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 ProductProperties. +func (p ProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductProperties. +func (p *ProductProperties) 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 "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 ProductUpdate. +func (p ProductUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductUpdate. +func (p *ProductUpdate) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProductUpdateProperties. +func (p ProductUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductUpdateProperties. +func (p *ProductUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &p.Description) + 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 ProofOfPossessionNonceRequest. +func (p ProofOfPossessionNonceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "proofOfPossessionNonce", p.ProofOfPossessionNonce) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProofOfPossessionNonceRequest. +func (p *ProofOfPossessionNonceRequest) 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 "proofOfPossessionNonce": + err = unpopulate(val, "ProofOfPossessionNonce", &p.ProofOfPossessionNonce) + 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 ProofOfPossessionNonceResponse. +func (p ProofOfPossessionNonceResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificate", p.Certificate) + populateTimeRFC3339(objectMap, "expiryUtc", p.ExpiryUTC) + populateTimeRFC3339(objectMap, "notBeforeUtc", p.NotBeforeUTC) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "status", p.Status) + populate(objectMap, "subject", p.Subject) + populate(objectMap, "thumbprint", p.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProofOfPossessionNonceResponse. +func (p *ProofOfPossessionNonceResponse) 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 "certificate": + err = unpopulate(val, "Certificate", &p.Certificate) + delete(rawMsg, key) + case "expiryUtc": + err = unpopulateTimeRFC3339(val, "ExpiryUTC", &p.ExpiryUTC) + delete(rawMsg, key) + case "notBeforeUtc": + err = unpopulateTimeRFC3339(val, "NotBeforeUTC", &p.NotBeforeUTC) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &p.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, "Thumbprint", &p.Thumbprint) + 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 SignedCapabilityImageResponse. +func (s SignedCapabilityImageResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "image", s.Image) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SignedCapabilityImageResponse. +func (s *SignedCapabilityImageResponse) 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 "image": + err = unpopulate(val, "Image", &s.Image) + 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 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 +} + +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 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/azuresphere/armazuresphere/operations_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/operations_client.go new file mode 100644 index 000000000000..a485be49581f --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/operations_client.go @@ -0,0 +1,102 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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 - List the operations for the provider +// +// Generated from API version 2022-09-01-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.AzureSphere/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", "2022-09-01-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/azuresphere/armazuresphere/products_client.go b/sdk/resourcemanager/azuresphere/armazuresphere/products_client.go new file mode 100644 index 000000000000..09cecfdce5df --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/products_client.go @@ -0,0 +1,542 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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" +) + +// ProductsClient contains the methods for the Products group. +// Don't use this type directly, use NewProductsClient() instead. +type ProductsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewProductsClient creates a new instance of ProductsClient 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 NewProductsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductsClient, error) { + cl, err := arm.NewClient(moduleName+".ProductsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProductsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CountDevices - Counts devices in product. '.default' and '.unassigned' are system defined values and cannot be used for +// product name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - options - ProductsClientCountDevicesOptions contains the optional parameters for the ProductsClient.CountDevices method. +func (client *ProductsClient) CountDevices(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientCountDevicesOptions) (ProductsClientCountDevicesResponse, error) { + req, err := client.countDevicesCreateRequest(ctx, resourceGroupName, catalogName, productName, options) + if err != nil { + return ProductsClientCountDevicesResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductsClientCountDevicesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientCountDevicesResponse{}, runtime.NewResponseError(resp) + } + return client.countDevicesHandleResponse(resp) +} + +// countDevicesCreateRequest creates the CountDevices request. +func (client *ProductsClient) countDevicesCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientCountDevicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/countDevices" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// countDevicesHandleResponse handles the CountDevices response. +func (client *ProductsClient) countDevicesHandleResponse(resp *http.Response) (ProductsClientCountDevicesResponse, error) { + result := ProductsClientCountDevicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CountDeviceResponse); err != nil { + return ProductsClientCountDevicesResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a Product. '.default' and '.unassigned' are system defined values and cannot be used for product +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - resource - Resource create parameters. +// - options - ProductsClientBeginCreateOrUpdateOptions contains the optional parameters for the ProductsClient.BeginCreateOrUpdate +// method. +func (client *ProductsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, resource Product, options *ProductsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ProductsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, catalogName, productName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProductsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProductsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Product. '.default' and '.unassigned' are system defined values and cannot be used for product +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *ProductsClient) createOrUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, resource Product, options *ProductsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, catalogName, productName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, resource Product, options *ProductsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name' +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - options - ProductsClientBeginDeleteOptions contains the optional parameters for the ProductsClient.BeginDelete method. +func (client *ProductsClient) BeginDelete(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientBeginDeleteOptions) (*runtime.Poller[ProductsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, catalogName, productName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProductsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[ProductsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name' +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *ProductsClient) deleteOperation(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, catalogName, productName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewGenerateDefaultDeviceGroupsPager - Generates default device groups for the product. '.default' and '.unassigned' are +// system defined values and cannot be used for product name. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - options - ProductsClientGenerateDefaultDeviceGroupsOptions contains the optional parameters for the ProductsClient.NewGenerateDefaultDeviceGroupsPager +// method. +func (client *ProductsClient) NewGenerateDefaultDeviceGroupsPager(resourceGroupName string, catalogName string, productName string, options *ProductsClientGenerateDefaultDeviceGroupsOptions) *runtime.Pager[ProductsClientGenerateDefaultDeviceGroupsResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductsClientGenerateDefaultDeviceGroupsResponse]{ + More: func(page ProductsClientGenerateDefaultDeviceGroupsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductsClientGenerateDefaultDeviceGroupsResponse) (ProductsClientGenerateDefaultDeviceGroupsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.generateDefaultDeviceGroupsCreateRequest(ctx, resourceGroupName, catalogName, productName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProductsClientGenerateDefaultDeviceGroupsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductsClientGenerateDefaultDeviceGroupsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientGenerateDefaultDeviceGroupsResponse{}, runtime.NewResponseError(resp) + } + return client.generateDefaultDeviceGroupsHandleResponse(resp) + }, + }) +} + +// generateDefaultDeviceGroupsCreateRequest creates the GenerateDefaultDeviceGroups request. +func (client *ProductsClient) generateDefaultDeviceGroupsCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientGenerateDefaultDeviceGroupsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/generateDefaultDeviceGroups" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// generateDefaultDeviceGroupsHandleResponse handles the GenerateDefaultDeviceGroups response. +func (client *ProductsClient) generateDefaultDeviceGroupsHandleResponse(resp *http.Response) (ProductsClientGenerateDefaultDeviceGroupsResponse, error) { + result := ProductsClientGenerateDefaultDeviceGroupsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeviceGroupListResult); err != nil { + return ProductsClientGenerateDefaultDeviceGroupsResponse{}, err + } + return result, nil +} + +// Get - Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - options - ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. +func (client *ProductsClient) Get(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientGetOptions) (ProductsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, catalogName, productName, options) + if err != nil { + return ProductsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProductsClient) getCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, options *ProductsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductsClient) getHandleResponse(resp *http.Response) (ProductsClientGetResponse, error) { + result := ProductsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil { + return ProductsClientGetResponse{}, err + } + return result, nil +} + +// NewListByCatalogPager - List Product resources by Catalog +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - options - ProductsClientListByCatalogOptions contains the optional parameters for the ProductsClient.NewListByCatalogPager +// method. +func (client *ProductsClient) NewListByCatalogPager(resourceGroupName string, catalogName string, options *ProductsClientListByCatalogOptions) *runtime.Pager[ProductsClientListByCatalogResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductsClientListByCatalogResponse]{ + More: func(page ProductsClientListByCatalogResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductsClientListByCatalogResponse) (ProductsClientListByCatalogResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByCatalogCreateRequest(ctx, resourceGroupName, catalogName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProductsClientListByCatalogResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductsClientListByCatalogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientListByCatalogResponse{}, runtime.NewResponseError(resp) + } + return client.listByCatalogHandleResponse(resp) + }, + }) +} + +// listByCatalogCreateRequest creates the ListByCatalog request. +func (client *ProductsClient) listByCatalogCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, options *ProductsClientListByCatalogOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCatalogHandleResponse handles the ListByCatalog response. +func (client *ProductsClient) listByCatalogHandleResponse(resp *http.Response) (ProductsClientListByCatalogResponse, error) { + result := ProductsClientListByCatalogResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductListResult); err != nil { + return ProductsClientListByCatalogResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - catalogName - Name of catalog +// - productName - Name of product. +// - properties - The resource properties to be updated. +// - options - ProductsClientBeginUpdateOptions contains the optional parameters for the ProductsClient.BeginUpdate method. +func (client *ProductsClient) BeginUpdate(ctx context.Context, resourceGroupName string, catalogName string, productName string, properties ProductUpdate, options *ProductsClientBeginUpdateOptions) (*runtime.Poller[ProductsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, catalogName, productName, properties, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProductsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[ProductsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-preview +func (client *ProductsClient) update(ctx context.Context, resourceGroupName string, catalogName string, productName string, properties ProductUpdate, options *ProductsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, catalogName, productName, properties, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ProductsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, catalogName string, productName string, properties ProductUpdate, options *ProductsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}" + 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 catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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", "2022-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/response_types.go b/sdk/resourcemanager/azuresphere/armazuresphere/response_types.go new file mode 100644 index 000000000000..535b5f3de0b5 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/response_types.go @@ -0,0 +1,238 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +// CatalogsClientCountDevicesResponse contains the response from method CatalogsClient.CountDevices. +type CatalogsClientCountDevicesResponse struct { + CountDeviceResponse +} + +// CatalogsClientCreateOrUpdateResponse contains the response from method CatalogsClient.BeginCreateOrUpdate. +type CatalogsClientCreateOrUpdateResponse struct { + Catalog +} + +// CatalogsClientDeleteResponse contains the response from method CatalogsClient.BeginDelete. +type CatalogsClientDeleteResponse struct { + // placeholder for future response values +} + +// CatalogsClientGetResponse contains the response from method CatalogsClient.Get. +type CatalogsClientGetResponse struct { + Catalog +} + +// CatalogsClientListByResourceGroupResponse contains the response from method CatalogsClient.NewListByResourceGroupPager. +type CatalogsClientListByResourceGroupResponse struct { + CatalogListResult +} + +// CatalogsClientListBySubscriptionResponse contains the response from method CatalogsClient.NewListBySubscriptionPager. +type CatalogsClientListBySubscriptionResponse struct { + CatalogListResult +} + +// CatalogsClientListDeploymentsResponse contains the response from method CatalogsClient.NewListDeploymentsPager. +type CatalogsClientListDeploymentsResponse struct { + DeploymentListResult +} + +// CatalogsClientListDeviceGroupsResponse contains the response from method CatalogsClient.NewListDeviceGroupsPager. +type CatalogsClientListDeviceGroupsResponse struct { + DeviceGroupListResult +} + +// CatalogsClientListDeviceInsightsResponse contains the response from method CatalogsClient.NewListDeviceInsightsPager. +type CatalogsClientListDeviceInsightsResponse struct { + PagedDeviceInsight +} + +// CatalogsClientListDevicesResponse contains the response from method CatalogsClient.NewListDevicesPager. +type CatalogsClientListDevicesResponse struct { + DeviceListResult +} + +// CatalogsClientUpdateResponse contains the response from method CatalogsClient.Update. +type CatalogsClientUpdateResponse struct { + Catalog +} + +// CertificatesClientGetResponse contains the response from method CertificatesClient.Get. +type CertificatesClientGetResponse struct { + Certificate +} + +// CertificatesClientListByCatalogResponse contains the response from method CertificatesClient.NewListByCatalogPager. +type CertificatesClientListByCatalogResponse struct { + CertificateListResult +} + +// CertificatesClientRetrieveCertChainResponse contains the response from method CertificatesClient.RetrieveCertChain. +type CertificatesClientRetrieveCertChainResponse struct { + CertificateChainResponse +} + +// CertificatesClientRetrieveProofOfPossessionNonceResponse contains the response from method CertificatesClient.RetrieveProofOfPossessionNonce. +type CertificatesClientRetrieveProofOfPossessionNonceResponse struct { + ProofOfPossessionNonceResponse +} + +// DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.BeginCreateOrUpdate. +type DeploymentsClientCreateOrUpdateResponse struct { + Deployment +} + +// DeploymentsClientDeleteResponse contains the response from method DeploymentsClient.BeginDelete. +type DeploymentsClientDeleteResponse struct { + // placeholder for future response values +} + +// DeploymentsClientGetResponse contains the response from method DeploymentsClient.Get. +type DeploymentsClientGetResponse struct { + Deployment +} + +// DeploymentsClientListByDeviceGroupResponse contains the response from method DeploymentsClient.NewListByDeviceGroupPager. +type DeploymentsClientListByDeviceGroupResponse struct { + DeploymentListResult +} + +// DeviceGroupsClientClaimDevicesResponse contains the response from method DeviceGroupsClient.BeginClaimDevices. +type DeviceGroupsClientClaimDevicesResponse struct { + // placeholder for future response values +} + +// DeviceGroupsClientCountDevicesResponse contains the response from method DeviceGroupsClient.CountDevices. +type DeviceGroupsClientCountDevicesResponse struct { + CountDeviceResponse +} + +// DeviceGroupsClientCreateOrUpdateResponse contains the response from method DeviceGroupsClient.BeginCreateOrUpdate. +type DeviceGroupsClientCreateOrUpdateResponse struct { + DeviceGroup +} + +// DeviceGroupsClientDeleteResponse contains the response from method DeviceGroupsClient.BeginDelete. +type DeviceGroupsClientDeleteResponse struct { + // placeholder for future response values +} + +// DeviceGroupsClientGetResponse contains the response from method DeviceGroupsClient.Get. +type DeviceGroupsClientGetResponse struct { + DeviceGroup +} + +// DeviceGroupsClientListByProductResponse contains the response from method DeviceGroupsClient.NewListByProductPager. +type DeviceGroupsClientListByProductResponse struct { + DeviceGroupListResult +} + +// DeviceGroupsClientUpdateResponse contains the response from method DeviceGroupsClient.BeginUpdate. +type DeviceGroupsClientUpdateResponse struct { + DeviceGroup +} + +// DevicesClientCreateOrUpdateResponse contains the response from method DevicesClient.BeginCreateOrUpdate. +type DevicesClientCreateOrUpdateResponse struct { + Device +} + +// DevicesClientDeleteResponse contains the response from method DevicesClient.BeginDelete. +type DevicesClientDeleteResponse struct { + // placeholder for future response values +} + +// DevicesClientGenerateCapabilityImageResponse contains the response from method DevicesClient.BeginGenerateCapabilityImage. +type DevicesClientGenerateCapabilityImageResponse struct { + SignedCapabilityImageResponse +} + +// DevicesClientGetResponse contains the response from method DevicesClient.Get. +type DevicesClientGetResponse struct { + Device +} + +// DevicesClientListByDeviceGroupResponse contains the response from method DevicesClient.NewListByDeviceGroupPager. +type DevicesClientListByDeviceGroupResponse struct { + DeviceListResult +} + +// DevicesClientUpdateResponse contains the response from method DevicesClient.BeginUpdate. +type DevicesClientUpdateResponse struct { + Device +} + +// ImagesClientCreateOrUpdateResponse contains the response from method ImagesClient.BeginCreateOrUpdate. +type ImagesClientCreateOrUpdateResponse struct { + Image +} + +// ImagesClientDeleteResponse contains the response from method ImagesClient.BeginDelete. +type ImagesClientDeleteResponse struct { + // placeholder for future response values +} + +// ImagesClientGetResponse contains the response from method ImagesClient.Get. +type ImagesClientGetResponse struct { + Image +} + +// ImagesClientListByCatalogResponse contains the response from method ImagesClient.NewListByCatalogPager. +type ImagesClientListByCatalogResponse struct { + ImageListResult +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + +// ProductsClientCountDevicesResponse contains the response from method ProductsClient.CountDevices. +type ProductsClientCountDevicesResponse struct { + CountDeviceResponse +} + +// ProductsClientCreateOrUpdateResponse contains the response from method ProductsClient.BeginCreateOrUpdate. +type ProductsClientCreateOrUpdateResponse struct { + Product +} + +// ProductsClientDeleteResponse contains the response from method ProductsClient.BeginDelete. +type ProductsClientDeleteResponse struct { + // placeholder for future response values +} + +// ProductsClientGenerateDefaultDeviceGroupsResponse contains the response from method ProductsClient.NewGenerateDefaultDeviceGroupsPager. +type ProductsClientGenerateDefaultDeviceGroupsResponse struct { + DeviceGroupListResult +} + +// ProductsClientGetResponse contains the response from method ProductsClient.Get. +type ProductsClientGetResponse struct { + Product +} + +// ProductsClientListByCatalogResponse contains the response from method ProductsClient.NewListByCatalogPager. +type ProductsClientListByCatalogResponse struct { + ProductListResult +} + +// ProductsClientUpdateResponse contains the response from method ProductsClient.BeginUpdate. +type ProductsClientUpdateResponse struct { + Product +} diff --git a/sdk/resourcemanager/azuresphere/armazuresphere/time_rfc3339.go b/sdk/resourcemanager/azuresphere/armazuresphere/time_rfc3339.go new file mode 100644 index 000000000000..ddd8a08c5dd3 --- /dev/null +++ b/sdk/resourcemanager/azuresphere/armazuresphere/time_rfc3339.go @@ -0,0 +1,95 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armazuresphere + +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 +}