diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/CHANGELOG.md b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/CHANGELOG.md new file mode 100644 index 000000000000..583239b7086f --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-10-24) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgemarketplace/armedgemarketplace` 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/edgemarketplace/armedgemarketplace/LICENSE.txt b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/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/edgemarketplace/armedgemarketplace/README.md b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/README.md new file mode 100644 index 000000000000..b2485e3782ba --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/README.md @@ -0,0 +1,85 @@ +# Azure Edgemarketplace Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgemarketplace/armedgemarketplace)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgemarketplace/armedgemarketplace) + +The `armedgemarketplace` module provides operations for working with Azure Edgemarketplace. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/edgemarketplace/armedgemarketplace) + +# 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 Edgemarketplace module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgemarketplace/armedgemarketplace +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Edgemarketplace. 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 Edgemarketplace 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 := armedgemarketplace.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, + }, +} +clientFactory, err := armedgemarketplace.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.NewPublishersClient() +``` + +## 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 `Edgemarketplace` 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/edgemarketplace/armedgemarketplace/autorest.md b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/autorest.md new file mode 100644 index 000000000000..744644ed90ff --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/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/edgemarketplace/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/edgemarketplace/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/edgemarketplace/armedgemarketplace/build.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/build.go new file mode 100644 index 000000000000..62702de00e5a --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/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/edgemarketplace/armedgemarketplace + +package armedgemarketplace diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/ci.yml b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/ci.yml new file mode 100644 index 000000000000..c809d6fae8f9 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/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/edgemarketplace/armedgemarketplace/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/edgemarketplace/armedgemarketplace/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/edgemarketplace/armedgemarketplace' diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/client_factory.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/client_factory.go new file mode 100644 index 000000000000..70365de6f71e --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/client_factory.go @@ -0,0 +1,53 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +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) NewOffersClient() *OffersClient { + subClient, _ := NewOffersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPublishersClient() *PublishersClient { + subClient, _ := NewPublishersClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/constants.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/constants.go new file mode 100644 index 000000000000..8502bf9386b2 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/constants.go @@ -0,0 +1,124 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +const ( + moduleName = "armedgemarketplace" + 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, + } +} + +// 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, + } +} + +// OfferAvailability - Says if the offer is public/private +type OfferAvailability string + +const ( + // OfferAvailabilityPrivate - The offer availability is private + OfferAvailabilityPrivate OfferAvailability = "Private" + // OfferAvailabilityPublic - The offer availability is public + OfferAvailabilityPublic OfferAvailability = "Public" +) + +// PossibleOfferAvailabilityValues returns the possible values for the OfferAvailability const type. +func PossibleOfferAvailabilityValues() []OfferAvailability { + return []OfferAvailability{ + OfferAvailabilityPrivate, + OfferAvailabilityPublic, + } +} + +// OfferReleaseType - Offer release type +type OfferReleaseType string + +const ( + // OfferReleaseTypeGA - The offer in GA + OfferReleaseTypeGA OfferReleaseType = "GA" + // OfferReleaseTypePreview - The offer in preview + OfferReleaseTypePreview OfferReleaseType = "Preview" +) + +// PossibleOfferReleaseTypeValues returns the possible values for the OfferReleaseType const type. +func PossibleOfferReleaseTypeValues() []OfferReleaseType { + return []OfferReleaseType{ + OfferReleaseTypeGA, + OfferReleaseTypePreview, + } +} + +// 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, + } +} + +// ResourceProvisioningState - The provisioning state of a resource type. +type ResourceProvisioningState string + +const ( + // ResourceProvisioningStateCanceled - Resource creation was canceled. + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + // ResourceProvisioningStateFailed - Resource creation failed. + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + // ResourceProvisioningStateSucceeded - Resource has been created. + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +// PossibleResourceProvisioningStateValues returns the possible values for the ResourceProvisioningState const type. +func PossibleResourceProvisioningStateValues() []ResourceProvisioningState { + return []ResourceProvisioningState{ + ResourceProvisioningStateCanceled, + ResourceProvisioningStateFailed, + ResourceProvisioningStateSucceeded, + } +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.mod b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.mod new file mode 100644 index 000000000000..59ec832455cc --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgemarketplace/armedgemarketplace + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.sum b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.sum new file mode 100644 index 000000000000..5c6bee428364 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/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.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/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/edgemarketplace/armedgemarketplace/models.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/models.go new file mode 100644 index 000000000000..ce4e3a6bcf9e --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/models.go @@ -0,0 +1,351 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +import "time" + +// AccessTokenReadRequest - Access token request object +type AccessTokenReadRequest struct { + // REQUIRED; The name of the publisher. + RequestID *string +} + +// AccessTokenRequest - Access token request object +type AccessTokenRequest struct { + // REQUIRED; The region where the disk will be created. + EdgeMarketPlaceRegion *string + + // The device sku. + DeviceSKU *string + + // The device sku version. + DeviceVersion *string + + // The region where the disk will be created. + EgeMarketPlaceResourceID *string + + // The hyperv version. + HypervGeneration *string + + // The marketplace sku. + MarketPlaceSKU *string + + // The marketplace sku version. + MarketPlaceSKUVersion *string + + // The name of the publisher. + PublisherName *string +} + +// DiskAccessToken - The disk access token +type DiskAccessToken struct { + // REQUIRED; The access token. + AccessToken *string + + // The disk id. + DiskID *string + + // The access token creation status. + Status *string +} + +// IconFileUris - Icon files +type IconFileUris struct { + // uri of large icon + Large *string + + // uri of medium icon + Medium *string + + // uri of small icon + Small *string + + // uri of wide icon + Wide *string +} + +// MarketplaceSKU - The marketplace sku +type MarketplaceSKU struct { + // REQUIRED; The catalog plan id + CatalogPlanID *string + + // REQUIRED; The marketplace sku id + MarketplaceSKUID *string + + // The description + Description *string + + // The display name of marketplace sku + DisplayName *string + + // The display rank of the sku + DisplayRank *int32 + + // The generation + Generation *string + + // The long summary + LongSummary *string + + // The marketplace sku version + MarketplaceSKUVersions []*MarketplaceSKUVersion + + // The operating system supported + OperatingSystem *SKUOperatingSystem + + // The summary + Summary *string + + // The type of marketplace sku + Type *string +} + +// MarketplaceSKUVersion - The marketplace sku version +type MarketplaceSKUVersion struct { + // REQUIRED; The name of sku version + Name *string + + // The size of the download + MinimumDownloadSizeInMb *int32 + + // The size of the image + SizeOnDiskInMb *int32 + + // The stage name + StageName *string +} + +// Offer - An offer. +type Offer struct { + // The resource-specific properties for this resource. + Properties *OfferProperties + + // 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 +} + +// OfferContent - The offer content +type OfferContent struct { + // REQUIRED; The display name of the offer + DisplayName *string + + // REQUIRED; The offer id + OfferID *string + + // The availability of the offer + Availability *OfferAvailability + + // The category ids + CategoryIDs []*string + + // The description + Description *string + + // The icon files + IconFileUris *IconFileUris + + // The long summary + LongSummary *string + + // The publisher of the offer + OfferPublisher *OfferPublisher + + // The offer type + OfferType *string + + // The operating systems + OperatingSystems []*string + + // The popularity of the offer + Popularity *int32 + + // The release type of the offer + ReleaseType *OfferReleaseType + + // The summary + Summary *string + + // The support uri + SupportURI *string + + // The terms and conditions + TermsAndConditions *TermsAndConditions +} + +// OfferListResult - The response of a Offer list operation. +type OfferListResult struct { + // REQUIRED; The Offer items on this page + Value []*Offer + + // The link to the next page of items + NextLink *string +} + +// OfferProperties - The offer properties +type OfferProperties struct { + // REQUIRED; The offer content + OfferContent *OfferContent + + // The content url + ContentURL *string + + // The content version + ContentVersion *string + + // The marketplace skus + MarketplaceSKUs []*MarketplaceSKU + + // The resource provisioning state + ProvisioningState *ResourceProvisioningState +} + +// OfferPublisher - The offer publisher +type OfferPublisher struct { + // REQUIRED; The publisher name + PublisherDisplayName *string + + // REQUIRED; The publisher Id + PublisherID *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 +} + +// Publisher - A publisher who provides offers. +type Publisher struct { + // The resource-specific properties for this resource. + Properties *PublisherProperties + + // 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 +} + +// PublisherListResult - The response of a Publisher list operation. +type PublisherListResult struct { + // REQUIRED; The Publisher items on this page + Value []*Publisher + + // The link to the next page of items + NextLink *string +} + +// PublisherProperties - Publisher properties +type PublisherProperties struct { + // REQUIRED; The resource provisioning state + ProvisioningState *ResourceProvisioningState +} + +// SKUOperatingSystem - The sku operating system +type SKUOperatingSystem struct { + // REQUIRED; The name of the operating system + Name *string + + // The family of the operating system + Family *string + + // The type of the operating system + Type *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 +} + +// TermsAndConditions - Terms and conditions +type TermsAndConditions struct { + // The type of legal terms + LegalTermsType *string + + // The legal terms and conditions uri + LegalTermsURI *string + + // The privacy policy uri + PrivacyPolicyURI *string +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/models_serde.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/models_serde.go new file mode 100644 index 000000000000..cb581196b503 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/models_serde.go @@ -0,0 +1,860 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccessTokenReadRequest. +func (a AccessTokenReadRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "requestId", a.RequestID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessTokenReadRequest. +func (a *AccessTokenReadRequest) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "requestId": + err = unpopulate(val, "RequestID", &a.RequestID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessTokenRequest. +func (a AccessTokenRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deviceSku", a.DeviceSKU) + populate(objectMap, "deviceVersion", a.DeviceVersion) + populate(objectMap, "edgeMarketPlaceRegion", a.EdgeMarketPlaceRegion) + populate(objectMap, "egeMarketPlaceResourceId", a.EgeMarketPlaceResourceID) + populate(objectMap, "hypervGeneration", a.HypervGeneration) + populate(objectMap, "marketPlaceSku", a.MarketPlaceSKU) + populate(objectMap, "marketPlaceSkuVersion", a.MarketPlaceSKUVersion) + populate(objectMap, "publisherName", a.PublisherName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessTokenRequest. +func (a *AccessTokenRequest) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deviceSku": + err = unpopulate(val, "DeviceSKU", &a.DeviceSKU) + delete(rawMsg, key) + case "deviceVersion": + err = unpopulate(val, "DeviceVersion", &a.DeviceVersion) + delete(rawMsg, key) + case "edgeMarketPlaceRegion": + err = unpopulate(val, "EdgeMarketPlaceRegion", &a.EdgeMarketPlaceRegion) + delete(rawMsg, key) + case "egeMarketPlaceResourceId": + err = unpopulate(val, "EgeMarketPlaceResourceID", &a.EgeMarketPlaceResourceID) + delete(rawMsg, key) + case "hypervGeneration": + err = unpopulate(val, "HypervGeneration", &a.HypervGeneration) + delete(rawMsg, key) + case "marketPlaceSku": + err = unpopulate(val, "MarketPlaceSKU", &a.MarketPlaceSKU) + delete(rawMsg, key) + case "marketPlaceSkuVersion": + err = unpopulate(val, "MarketPlaceSKUVersion", &a.MarketPlaceSKUVersion) + delete(rawMsg, key) + case "publisherName": + err = unpopulate(val, "PublisherName", &a.PublisherName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiskAccessToken. +func (d DiskAccessToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessToken", d.AccessToken) + populate(objectMap, "diskId", d.DiskID) + populate(objectMap, "status", d.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiskAccessToken. +func (d *DiskAccessToken) 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 "accessToken": + err = unpopulate(val, "AccessToken", &d.AccessToken) + delete(rawMsg, key) + case "diskId": + err = unpopulate(val, "DiskID", &d.DiskID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &d.Status) + 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 IconFileUris. +func (i IconFileUris) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "large", i.Large) + populate(objectMap, "medium", i.Medium) + populate(objectMap, "small", i.Small) + populate(objectMap, "wide", i.Wide) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IconFileUris. +func (i *IconFileUris) 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 "large": + err = unpopulate(val, "Large", &i.Large) + delete(rawMsg, key) + case "medium": + err = unpopulate(val, "Medium", &i.Medium) + delete(rawMsg, key) + case "small": + err = unpopulate(val, "Small", &i.Small) + delete(rawMsg, key) + case "wide": + err = unpopulate(val, "Wide", &i.Wide) + 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 MarketplaceSKU. +func (m MarketplaceSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "catalogPlanId", m.CatalogPlanID) + populate(objectMap, "description", m.Description) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "displayRank", m.DisplayRank) + populate(objectMap, "generation", m.Generation) + populate(objectMap, "longSummary", m.LongSummary) + populate(objectMap, "marketplaceSkuId", m.MarketplaceSKUID) + populate(objectMap, "marketplaceSkuVersions", m.MarketplaceSKUVersions) + populate(objectMap, "operatingSystem", m.OperatingSystem) + populate(objectMap, "summary", m.Summary) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceSKU. +func (m *MarketplaceSKU) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "catalogPlanId": + err = unpopulate(val, "CatalogPlanID", &m.CatalogPlanID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &m.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "displayRank": + err = unpopulate(val, "DisplayRank", &m.DisplayRank) + delete(rawMsg, key) + case "generation": + err = unpopulate(val, "Generation", &m.Generation) + delete(rawMsg, key) + case "longSummary": + err = unpopulate(val, "LongSummary", &m.LongSummary) + delete(rawMsg, key) + case "marketplaceSkuId": + err = unpopulate(val, "MarketplaceSKUID", &m.MarketplaceSKUID) + delete(rawMsg, key) + case "marketplaceSkuVersions": + err = unpopulate(val, "MarketplaceSKUVersions", &m.MarketplaceSKUVersions) + delete(rawMsg, key) + case "operatingSystem": + err = unpopulate(val, "OperatingSystem", &m.OperatingSystem) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &m.Summary) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MarketplaceSKUVersion. +func (m MarketplaceSKUVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "minimumDownloadSizeInMb", m.MinimumDownloadSizeInMb) + populate(objectMap, "name", m.Name) + populate(objectMap, "sizeOnDiskInMb", m.SizeOnDiskInMb) + populate(objectMap, "stageName", m.StageName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceSKUVersion. +func (m *MarketplaceSKUVersion) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "minimumDownloadSizeInMb": + err = unpopulate(val, "MinimumDownloadSizeInMb", &m.MinimumDownloadSizeInMb) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "sizeOnDiskInMb": + err = unpopulate(val, "SizeOnDiskInMb", &m.SizeOnDiskInMb) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &m.StageName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Offer. +func (o Offer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Offer. +func (o *Offer) 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 "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 OfferContent. +func (o OfferContent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availability", o.Availability) + populate(objectMap, "categoryIds", o.CategoryIDs) + populate(objectMap, "description", o.Description) + populate(objectMap, "displayName", o.DisplayName) + populate(objectMap, "iconFileUris", o.IconFileUris) + populate(objectMap, "longSummary", o.LongSummary) + populate(objectMap, "offerId", o.OfferID) + populate(objectMap, "offerPublisher", o.OfferPublisher) + populate(objectMap, "offerType", o.OfferType) + populate(objectMap, "operatingSystems", o.OperatingSystems) + populate(objectMap, "popularity", o.Popularity) + populate(objectMap, "releaseType", o.ReleaseType) + populate(objectMap, "summary", o.Summary) + populate(objectMap, "supportUri", o.SupportURI) + populate(objectMap, "termsAndConditions", o.TermsAndConditions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferContent. +func (o *OfferContent) 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 "availability": + err = unpopulate(val, "Availability", &o.Availability) + delete(rawMsg, key) + case "categoryIds": + err = unpopulate(val, "CategoryIDs", &o.CategoryIDs) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &o.DisplayName) + delete(rawMsg, key) + case "iconFileUris": + err = unpopulate(val, "IconFileUris", &o.IconFileUris) + delete(rawMsg, key) + case "longSummary": + err = unpopulate(val, "LongSummary", &o.LongSummary) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &o.OfferID) + delete(rawMsg, key) + case "offerPublisher": + err = unpopulate(val, "OfferPublisher", &o.OfferPublisher) + delete(rawMsg, key) + case "offerType": + err = unpopulate(val, "OfferType", &o.OfferType) + delete(rawMsg, key) + case "operatingSystems": + err = unpopulate(val, "OperatingSystems", &o.OperatingSystems) + delete(rawMsg, key) + case "popularity": + err = unpopulate(val, "Popularity", &o.Popularity) + delete(rawMsg, key) + case "releaseType": + err = unpopulate(val, "ReleaseType", &o.ReleaseType) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &o.Summary) + delete(rawMsg, key) + case "supportUri": + err = unpopulate(val, "SupportURI", &o.SupportURI) + delete(rawMsg, key) + case "termsAndConditions": + err = unpopulate(val, "TermsAndConditions", &o.TermsAndConditions) + 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 OfferListResult. +func (o OfferListResult) 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 OfferListResult. +func (o *OfferListResult) 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 OfferProperties. +func (o OfferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentUrl", o.ContentURL) + populate(objectMap, "contentVersion", o.ContentVersion) + populate(objectMap, "marketplaceSkus", o.MarketplaceSKUs) + populate(objectMap, "offerContent", o.OfferContent) + populate(objectMap, "provisioningState", o.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferProperties. +func (o *OfferProperties) 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 "contentUrl": + err = unpopulate(val, "ContentURL", &o.ContentURL) + delete(rawMsg, key) + case "contentVersion": + err = unpopulate(val, "ContentVersion", &o.ContentVersion) + delete(rawMsg, key) + case "marketplaceSkus": + err = unpopulate(val, "MarketplaceSKUs", &o.MarketplaceSKUs) + delete(rawMsg, key) + case "offerContent": + err = unpopulate(val, "OfferContent", &o.OfferContent) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + 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 OfferPublisher. +func (o OfferPublisher) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "publisherDisplayName", o.PublisherDisplayName) + populate(objectMap, "publisherId", o.PublisherID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferPublisher. +func (o *OfferPublisher) 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 "publisherDisplayName": + err = unpopulate(val, "PublisherDisplayName", &o.PublisherDisplayName) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &o.PublisherID) + 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 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 Publisher. +func (p Publisher) 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 Publisher. +func (p *Publisher) 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 PublisherListResult. +func (p PublisherListResult) 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 PublisherListResult. +func (p *PublisherListResult) 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 PublisherProperties. +func (p PublisherProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PublisherProperties. +func (p *PublisherProperties) 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 "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 SKUOperatingSystem. +func (s SKUOperatingSystem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUOperatingSystem. +func (s *SKUOperatingSystem) 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 "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 +} + +// MarshalJSON implements the json.Marshaller interface for type TermsAndConditions. +func (t TermsAndConditions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "legalTermsType", t.LegalTermsType) + populate(objectMap, "legalTermsUri", t.LegalTermsURI) + populate(objectMap, "privacyPolicyUri", t.PrivacyPolicyURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TermsAndConditions. +func (t *TermsAndConditions) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "legalTermsType": + err = unpopulate(val, "LegalTermsType", &t.LegalTermsType) + delete(rawMsg, key) + case "legalTermsUri": + err = unpopulate(val, "LegalTermsURI", &t.LegalTermsURI) + delete(rawMsg, key) + case "privacyPolicyUri": + err = unpopulate(val, "PrivacyPolicyURI", &t.PrivacyPolicyURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, 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/edgemarketplace/armedgemarketplace/offers_client.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/offers_client.go new file mode 100644 index 000000000000..d49b16a3d7e2 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/offers_client.go @@ -0,0 +1,369 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +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" +) + +// OffersClient contains the methods for the Offers group. +// Don't use this type directly, use NewOffersClient() instead. +type OffersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOffersClient creates a new instance of OffersClient 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 NewOffersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OffersClient, error) { + cl, err := arm.NewClient(moduleName+".OffersClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OffersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginGenerateAccessToken - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - offerID - Id of the offer +// - body - The content of the action request +// - options - OffersClientBeginGenerateAccessTokenOptions contains the optional parameters for the OffersClient.BeginGenerateAccessToken +// method. +func (client *OffersClient) BeginGenerateAccessToken(ctx context.Context, resourceURI string, offerID string, body AccessTokenRequest, options *OffersClientBeginGenerateAccessTokenOptions) (*runtime.Poller[OffersClientGenerateAccessTokenResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateAccessToken(ctx, resourceURI, offerID, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OffersClientGenerateAccessTokenResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[OffersClientGenerateAccessTokenResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateAccessToken - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01-preview +func (client *OffersClient) generateAccessToken(ctx context.Context, resourceURI string, offerID string, body AccessTokenRequest, options *OffersClientBeginGenerateAccessTokenOptions) (*http.Response, error) { + var err error + req, err := client.generateAccessTokenCreateRequest(ctx, resourceURI, offerID, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateAccessTokenCreateRequest creates the GenerateAccessToken request. +func (client *OffersClient) generateAccessTokenCreateRequest(ctx context.Context, resourceURI string, offerID string, body AccessTokenRequest, options *OffersClientBeginGenerateAccessTokenOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}/generateAccessToken" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get a Offer +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - offerID - Id of the offer +// - options - OffersClientGetOptions contains the optional parameters for the OffersClient.Get method. +func (client *OffersClient) Get(ctx context.Context, resourceURI string, offerID string, options *OffersClientGetOptions) (OffersClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceURI, offerID, options) + if err != nil { + return OffersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OffersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OffersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OffersClient) getCreateRequest(ctx context.Context, resourceURI string, offerID string, options *OffersClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-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 *OffersClient) getHandleResponse(resp *http.Response) (OffersClientGetResponse, error) { + result := OffersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Offer); err != nil { + return OffersClientGetResponse{}, err + } + return result, nil +} + +// GetAccessToken - get access token. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - offerID - Id of the offer +// - body - The content of the action request +// - options - OffersClientGetAccessTokenOptions contains the optional parameters for the OffersClient.GetAccessToken method. +func (client *OffersClient) GetAccessToken(ctx context.Context, resourceURI string, offerID string, body AccessTokenReadRequest, options *OffersClientGetAccessTokenOptions) (OffersClientGetAccessTokenResponse, error) { + var err error + req, err := client.getAccessTokenCreateRequest(ctx, resourceURI, offerID, body, options) + if err != nil { + return OffersClientGetAccessTokenResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OffersClientGetAccessTokenResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OffersClientGetAccessTokenResponse{}, err + } + resp, err := client.getAccessTokenHandleResponse(httpResp) + return resp, err +} + +// getAccessTokenCreateRequest creates the GetAccessToken request. +func (client *OffersClient) getAccessTokenCreateRequest(ctx context.Context, resourceURI string, offerID string, body AccessTokenReadRequest, options *OffersClientGetAccessTokenOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/offers/{offerId}/getAccessToken" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// getAccessTokenHandleResponse handles the GetAccessToken response. +func (client *OffersClient) getAccessTokenHandleResponse(resp *http.Response) (OffersClientGetAccessTokenResponse, error) { + result := OffersClientGetAccessTokenResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiskAccessToken); err != nil { + return OffersClientGetAccessTokenResponse{}, err + } + return result, nil +} + +// NewListPager - List Offer resources by parent +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - OffersClientListOptions contains the optional parameters for the OffersClient.NewListPager method. +func (client *OffersClient) NewListPager(resourceURI string, options *OffersClientListOptions) *runtime.Pager[OffersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OffersClientListResponse]{ + More: func(page OffersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OffersClientListResponse) (OffersClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OffersClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OffersClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OffersClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OffersClient) listCreateRequest(ctx context.Context, resourceURI string, options *OffersClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/offers" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + 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)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OffersClient) listHandleResponse(resp *http.Response) (OffersClientListResponse, error) { + result := OffersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OfferListResult); err != nil { + return OffersClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Offer resources by subscription +// +// Generated from API version 2023-08-01-preview +// - options - OffersClientListBySubscriptionOptions contains the optional parameters for the OffersClient.NewListBySubscriptionPager +// method. +func (client *OffersClient) NewListBySubscriptionPager(options *OffersClientListBySubscriptionOptions) *runtime.Pager[OffersClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[OffersClientListBySubscriptionResponse]{ + More: func(page OffersClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OffersClientListBySubscriptionResponse) (OffersClientListBySubscriptionResponse, 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 OffersClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OffersClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OffersClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *OffersClient) listBySubscriptionCreateRequest(ctx context.Context, options *OffersClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeMarketplace/offers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + 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)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *OffersClient) listBySubscriptionHandleResponse(resp *http.Response) (OffersClientListBySubscriptionResponse, error) { + result := OffersClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OfferListResult); err != nil { + return OffersClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/operations_client.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/operations_client.go new file mode 100644 index 000000000000..c8dd1a2321a0 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/operations_client.go @@ -0,0 +1,93 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +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 2023-08-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.EdgeMarketplace/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-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/edgemarketplace/armedgemarketplace/options.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/options.go new file mode 100644 index 000000000000..71e642d8cb27 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/options.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +// OffersClientBeginGenerateAccessTokenOptions contains the optional parameters for the OffersClient.BeginGenerateAccessToken +// method. +type OffersClientBeginGenerateAccessTokenOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OffersClientGetAccessTokenOptions contains the optional parameters for the OffersClient.GetAccessToken method. +type OffersClientGetAccessTokenOptions struct { + // placeholder for future optional parameters +} + +// OffersClientGetOptions contains the optional parameters for the OffersClient.Get method. +type OffersClientGetOptions struct { + // placeholder for future optional parameters +} + +// OffersClientListBySubscriptionOptions contains the optional parameters for the OffersClient.NewListBySubscriptionPager +// method. +type OffersClientListBySubscriptionOptions 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 + + // Skip over when retrieving results. + SkipToken *string + + // The number of result items to return. + Top *int32 +} + +// OffersClientListOptions contains the optional parameters for the OffersClient.NewListPager method. +type OffersClientListOptions 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 + + // Skip over when retrieving results. + SkipToken *string + + // The number of result items to return. + Top *int32 +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PublishersClientGetOptions contains the optional parameters for the PublishersClient.Get method. +type PublishersClientGetOptions struct { + // placeholder for future optional parameters +} + +// PublishersClientListBySubscriptionOptions contains the optional parameters for the PublishersClient.NewListBySubscriptionPager +// method. +type PublishersClientListBySubscriptionOptions 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 + + // Skip over when retrieving results. + SkipToken *string + + // The number of result items to return. + Top *int32 +} + +// PublishersClientListOptions contains the optional parameters for the PublishersClient.NewListPager method. +type PublishersClientListOptions 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 + + // Skip over when retrieving results. + SkipToken *string + + // The number of result items to return. + Top *int32 +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/publishers_client.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/publishers_client.go new file mode 100644 index 000000000000..7686984fa893 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/publishers_client.go @@ -0,0 +1,245 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +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" +) + +// PublishersClient contains the methods for the Publishers group. +// Don't use this type directly, use NewPublishersClient() instead. +type PublishersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPublishersClient creates a new instance of PublishersClient 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 NewPublishersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PublishersClient, error) { + cl, err := arm.NewClient(moduleName+".PublishersClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PublishersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get a Publisher +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - publisherName - Name of the publisher +// - options - PublishersClientGetOptions contains the optional parameters for the PublishersClient.Get method. +func (client *PublishersClient) Get(ctx context.Context, resourceURI string, publisherName string, options *PublishersClientGetOptions) (PublishersClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceURI, publisherName, options) + if err != nil { + return PublishersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PublishersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PublishersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PublishersClient) getCreateRequest(ctx context.Context, resourceURI string, publisherName string, options *PublishersClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/publishers/{publisherName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if publisherName == "" { + return nil, errors.New("parameter publisherName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{publisherName}", url.PathEscape(publisherName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-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 *PublishersClient) getHandleResponse(resp *http.Response) (PublishersClientGetResponse, error) { + result := PublishersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Publisher); err != nil { + return PublishersClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List Publisher resources by parent +// +// Generated from API version 2023-08-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - PublishersClientListOptions contains the optional parameters for the PublishersClient.NewListPager method. +func (client *PublishersClient) NewListPager(resourceURI string, options *PublishersClientListOptions) *runtime.Pager[PublishersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[PublishersClientListResponse]{ + More: func(page PublishersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PublishersClientListResponse) (PublishersClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PublishersClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PublishersClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PublishersClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *PublishersClient) listCreateRequest(ctx context.Context, resourceURI string, options *PublishersClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.EdgeMarketplace/publishers" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + 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)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PublishersClient) listHandleResponse(resp *http.Response) (PublishersClientListResponse, error) { + result := PublishersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PublisherListResult); err != nil { + return PublishersClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Publisher resources in subscription +// +// Generated from API version 2023-08-01-preview +// - options - PublishersClientListBySubscriptionOptions contains the optional parameters for the PublishersClient.NewListBySubscriptionPager +// method. +func (client *PublishersClient) NewListBySubscriptionPager(options *PublishersClientListBySubscriptionOptions) *runtime.Pager[PublishersClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[PublishersClientListBySubscriptionResponse]{ + More: func(page PublishersClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PublishersClientListBySubscriptionResponse) (PublishersClientListBySubscriptionResponse, 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 PublishersClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PublishersClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PublishersClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PublishersClient) listBySubscriptionCreateRequest(ctx context.Context, options *PublishersClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.EdgeMarketplace/publishers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01-preview") + 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)) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PublishersClient) listBySubscriptionHandleResponse(resp *http.Response) (PublishersClientListBySubscriptionResponse, error) { + result := PublishersClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PublisherListResult); err != nil { + return PublishersClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/response_types.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/response_types.go new file mode 100644 index 000000000000..419cd5a07129 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/response_types.go @@ -0,0 +1,63 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +// OffersClientGenerateAccessTokenResponse contains the response from method OffersClient.BeginGenerateAccessToken. +type OffersClientGenerateAccessTokenResponse struct { + // The disk access token + DiskAccessToken +} + +// OffersClientGetAccessTokenResponse contains the response from method OffersClient.GetAccessToken. +type OffersClientGetAccessTokenResponse struct { + // The disk access token + DiskAccessToken +} + +// OffersClientGetResponse contains the response from method OffersClient.Get. +type OffersClientGetResponse struct { + // An offer. + Offer +} + +// OffersClientListBySubscriptionResponse contains the response from method OffersClient.NewListBySubscriptionPager. +type OffersClientListBySubscriptionResponse struct { + // The response of a Offer list operation. + OfferListResult +} + +// OffersClientListResponse contains the response from method OffersClient.NewListPager. +type OffersClientListResponse struct { + // The response of a Offer list operation. + OfferListResult +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// PublishersClientGetResponse contains the response from method PublishersClient.Get. +type PublishersClientGetResponse struct { + // A publisher who provides offers. + Publisher +} + +// PublishersClientListBySubscriptionResponse contains the response from method PublishersClient.NewListBySubscriptionPager. +type PublishersClientListBySubscriptionResponse struct { + // The response of a Publisher list operation. + PublisherListResult +} + +// PublishersClientListResponse contains the response from method PublishersClient.NewListPager. +type PublishersClientListResponse struct { + // The response of a Publisher list operation. + PublisherListResult +} diff --git a/sdk/resourcemanager/edgemarketplace/armedgemarketplace/time_rfc3339.go b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/time_rfc3339.go new file mode 100644 index 000000000000..263e03103973 --- /dev/null +++ b/sdk/resourcemanager/edgemarketplace/armedgemarketplace/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armedgemarketplace + +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 +}