diff --git a/sdk/resourcemanager/marketplace/armmarketplace/CHANGELOG.md b/sdk/resourcemanager/marketplace/armmarketplace/CHANGELOG.md new file mode 100644 index 000000000000..925a954ff70d --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-07) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/marketplace/armmarketplace/LICENSE.txt b/sdk/resourcemanager/marketplace/armmarketplace/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/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/marketplace/armmarketplace/README.md b/sdk/resourcemanager/marketplace/armmarketplace/README.md new file mode 100644 index 000000000000..46ba5a520dd6 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/README.md @@ -0,0 +1,75 @@ +# Azure Marketplace Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplace/armmarketplace)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplace/armmarketplace) + +The `armmarketplace` module provides operations for working with Azure Marketplace. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/marketplace/armmarketplace) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Marketplace module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplace/armmarketplace +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Marketplace. 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). + +## Clients + +Azure Marketplace modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client := armmarketplace.(, 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{ + Host: arm.AzureChina, +} +client := armmarketplace.(, cred, &options) +``` + +## 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 `Marketplace` 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/marketplace/armmarketplace/autorest.md b/sdk/resourcemanager/marketplace/armmarketplace/autorest.md new file mode 100644 index 000000000000..c94fa6a55b51 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/marketplace/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/marketplace/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/marketplace/armmarketplace/build.go b/sdk/resourcemanager/marketplace/armmarketplace/build.go new file mode 100644 index 000000000000..a9388ccec709 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/marketplace/armmarketplace + +package armmarketplace diff --git a/sdk/resourcemanager/marketplace/armmarketplace/ci.yml b/sdk/resourcemanager/marketplace/armmarketplace/ci.yml new file mode 100644 index 000000000000..4dd529c71c6c --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/ci.yml @@ -0,0 +1,27 @@ +# 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/marketplace/armmarketplace/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/marketplace/armmarketplace/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/marketplace/armmarketplace' diff --git a/sdk/resourcemanager/marketplace/armmarketplace/go.mod b/sdk/resourcemanager/marketplace/armmarketplace/go.mod new file mode 100644 index 000000000000..6b88756e9a36 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplace/armmarketplace + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.0.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/marketplace/armmarketplace/go.sum b/sdk/resourcemanager/marketplace/armmarketplace/go.sum new file mode 100644 index 000000000000..4cb1a2cbfc46 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ= +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/marketplace/armmarketplace/go_mod_tidy_hack.go b/sdk/resourcemanager/marketplace/armmarketplace/go_mod_tidy_hack.go new file mode 100644 index 000000000000..00f5dd67ea65 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armmarketplace + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_constants.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_constants.go new file mode 100644 index 000000000000..6fb4603615a7 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_constants.go @@ -0,0 +1,156 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +const ( + module = "armmarketplace" + version = "v0.1.0" +) + +// Accessibility - Plan accessibility +type Accessibility string + +const ( + AccessibilityPrivateSubscriptionOnLevel Accessibility = "PrivateSubscriptionOnLevel" + AccessibilityPrivateTenantOnLevel Accessibility = "PrivateTenantOnLevel" + AccessibilityPublic Accessibility = "Public" + AccessibilityUnknown Accessibility = "Unknown" +) + +// PossibleAccessibilityValues returns the possible values for the Accessibility const type. +func PossibleAccessibilityValues() []Accessibility { + return []Accessibility{ + AccessibilityPrivateSubscriptionOnLevel, + AccessibilityPrivateTenantOnLevel, + AccessibilityPublic, + AccessibilityUnknown, + } +} + +// ToPtr returns a *Accessibility pointing to the current value. +func (c Accessibility) ToPtr() *Accessibility { + return &c +} + +// AdminAction - Gets or sets admin action +type AdminAction string + +const ( + AdminActionApproved AdminAction = "Approved" + AdminActionRejected AdminAction = "Rejected" +) + +// PossibleAdminActionValues returns the possible values for the AdminAction const type. +func PossibleAdminActionValues() []AdminAction { + return []AdminAction{ + AdminActionApproved, + AdminActionRejected, + } +} + +// ToPtr returns a *AdminAction pointing to the current value. +func (c AdminAction) ToPtr() *AdminAction { + return &c +} + +// Availability - Indicates private store availability +type Availability string + +const ( + AvailabilityDisabled Availability = "disabled" + AvailabilityEnabled Availability = "enabled" +) + +// PossibleAvailabilityValues returns the possible values for the Availability const type. +func PossibleAvailabilityValues() []Availability { + return []Availability{ + AvailabilityDisabled, + AvailabilityEnabled, + } +} + +// ToPtr returns a *Availability pointing to the current value. +func (c Availability) ToPtr() *Availability { + return &c +} + +// IdentityType - The type of identity that creates/modifies resources +type IdentityType string + +const ( + IdentityTypeApplication IdentityType = "Application" + IdentityTypeKey IdentityType = "Key" + IdentityTypeManagedIdentity IdentityType = "ManagedIdentity" + IdentityTypeUser IdentityType = "User" +) + +// PossibleIdentityTypeValues returns the possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{ + IdentityTypeApplication, + IdentityTypeKey, + IdentityTypeManagedIdentity, + IdentityTypeUser, + } +} + +// ToPtr returns a *IdentityType pointing to the current value. +func (c IdentityType) ToPtr() *IdentityType { + return &c +} + +// Operation - Set the Operation for the POST method. Ping or Delete +type Operation string + +const ( + OperationDeletePrivateStoreCollection Operation = "DeletePrivateStoreCollection" + OperationDeletePrivateStoreCollectionOffer Operation = "DeletePrivateStoreCollectionOffer" + OperationDeletePrivateStoreOffer Operation = "DeletePrivateStoreOffer" + OperationPing Operation = "Ping" +) + +// PossibleOperationValues returns the possible values for the Operation const type. +func PossibleOperationValues() []Operation { + return []Operation{ + OperationDeletePrivateStoreCollection, + OperationDeletePrivateStoreCollectionOffer, + OperationDeletePrivateStoreOffer, + OperationPing, + } +} + +// ToPtr returns a *Operation pointing to the current value. +func (c Operation) ToPtr() *Operation { + return &c +} + +// Status - Gets the plan status +type Status string + +const ( + StatusApproved Status = "Approved" + StatusNone Status = "None" + StatusPending Status = "Pending" + StatusRejected Status = "Rejected" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusApproved, + StatusNone, + StatusPending, + StatusRejected, + } +} + +// ToPtr returns a *Status pointing to the current value. +func (c Status) ToPtr() *Status { + return &c +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_models.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_models.go new file mode 100644 index 000000000000..3dbb4ff69027 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_models.go @@ -0,0 +1,1237 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AcknowledgeOfferNotificationDetails - Notification update request payload details +type AcknowledgeOfferNotificationDetails struct { + // Gets or sets a value indicating whether acknowledge action flag is enabled + Acknowledge *bool `json:"acknowledge,omitempty"` + + // Gets or sets added plans + AddPlans []*string `json:"addPlans,omitempty"` + + // Gets or sets a value indicating whether dismiss action flag is enabled + Dismiss *bool `json:"dismiss,omitempty"` + + // Gets or sets a value indicating whether remove offer action flag is enabled + RemoveOffer *bool `json:"removeOffer,omitempty"` + + // Gets or sets remove plans + RemovePlans []*string `json:"removePlans,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AcknowledgeOfferNotificationDetails. +func (a AcknowledgeOfferNotificationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "acknowledge", a.Acknowledge) + populate(objectMap, "addPlans", a.AddPlans) + populate(objectMap, "dismiss", a.Dismiss) + populate(objectMap, "removeOffer", a.RemoveOffer) + populate(objectMap, "removePlans", a.RemovePlans) + return json.Marshal(objectMap) +} + +// AcknowledgeOfferNotificationProperties - Notification update request payload +type AcknowledgeOfferNotificationProperties struct { + // Notification update request payload details + Properties *AcknowledgeOfferNotificationDetails `json:"properties,omitempty"` +} + +// AdminRequestApprovalProperties - Admin approval request resource properties +type AdminRequestApprovalProperties struct { + // Gets or sets admin action + AdminAction *AdminAction `json:"adminAction,omitempty"` + + // Gets or sets admin details + Administrator *string `json:"administrator,omitempty"` + + // Gets or sets Approved plans ids, empty in case of rejected + ApprovedPlans []*string `json:"approvedPlans,omitempty"` + + // Gets or sets list of associated collection ids + CollectionIDs []*string `json:"collectionIds,omitempty"` + + // Gets or sets admin comment + Comment *string `json:"comment,omitempty"` + + // Gets or sets offer Id + OfferID *string `json:"offerId,omitempty"` + + // Gets or sets publisher Id + PublisherID *string `json:"publisherId,omitempty"` + + // READ-ONLY; Gets display name + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Gets list of plans with requesters details + Plans []*PlanRequesterDetails `json:"plans,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AdminRequestApprovalProperties. +func (a AdminRequestApprovalProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminAction", a.AdminAction) + populate(objectMap, "administrator", a.Administrator) + populate(objectMap, "approvedPlans", a.ApprovedPlans) + populate(objectMap, "collectionIds", a.CollectionIDs) + populate(objectMap, "comment", a.Comment) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "offerId", a.OfferID) + populate(objectMap, "plans", a.Plans) + populate(objectMap, "publisherId", a.PublisherID) + return json.Marshal(objectMap) +} + +// AdminRequestApprovalsList - List of admin request approval resources +type AdminRequestApprovalsList struct { + Value []*AdminRequestApprovalsResource `json:"value,omitempty"` + + // READ-ONLY; URL to get the next set of notifications list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AdminRequestApprovalsList. +func (a AdminRequestApprovalsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AdminRequestApprovalsResource - Admin request approval resource. +type AdminRequestApprovalsResource struct { + Resource + // The privateStore admin Approval request data structure. + Properties *AdminRequestApprovalProperties `json:"properties,omitempty"` +} + +// BillingAccountsResponse - Billing accounts response object +type BillingAccountsResponse struct { + // Billing accounts list + BillingAccounts []*string `json:"billingAccounts,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BillingAccountsResponse. +func (b BillingAccountsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingAccounts", b.BillingAccounts) + return json.Marshal(objectMap) +} + +// BulkCollectionsDetails - Bulk collection details +type BulkCollectionsDetails struct { + // Action to perform (For example: EnableCollections, DisableCollections) + Action *string `json:"action,omitempty"` + + // collection ids list that the action is performed on + CollectionIDs []*string `json:"collectionIds,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BulkCollectionsDetails. +func (b BulkCollectionsDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", b.Action) + populate(objectMap, "collectionIds", b.CollectionIDs) + return json.Marshal(objectMap) +} + +// BulkCollectionsPayload - Bulk collections action properties +type BulkCollectionsPayload struct { + // bulk collections properties details + Properties *BulkCollectionsDetails `json:"properties,omitempty"` +} + +// BulkCollectionsResponse - The bulk collections response. The response contains two lists that indicate for each collection whether the operation succeeded +// or failed +type BulkCollectionsResponse struct { + // Failed collections + Failed []*CollectionsDetails `json:"failed,omitempty"` + + // Succeeded collections + Succeeded []*CollectionsDetails `json:"succeeded,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BulkCollectionsResponse. +func (b BulkCollectionsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "failed", b.Failed) + populate(objectMap, "succeeded", b.Succeeded) + return json.Marshal(objectMap) +} + +// Collection - The Collection data structure. +type Collection struct { + Resource + // The collection data structure. + Properties *CollectionProperties `json:"properties,omitempty"` +} + +// CollectionProperties - The collection details +type CollectionProperties struct { + // Indicating whether all subscriptions are selected (=true) or not (=false). + AllSubscriptions *bool `json:"allSubscriptions,omitempty"` + + // Gets or sets the association with Commercial's Billing Account. + Claim *string `json:"claim,omitempty"` + + // Gets or sets collection name. + CollectionName *string `json:"collectionName,omitempty"` + + // Indicating whether the collection is enabled or disabled. + Enabled *bool `json:"enabled,omitempty"` + + // Gets or sets subscription ids list. Empty list indicates all subscriptions are selected, null indicates no update is done, explicit list indicates the + // explicit selected subscriptions. On insert, null + // is considered as bad request + SubscriptionsList []*string `json:"subscriptionsList,omitempty"` + + // READ-ONLY; Gets collection Id. + CollectionID *string `json:"collectionId,omitempty" azure:"ro"` + + // READ-ONLY; Gets the number of offers associated with the collection. + NumberOfOffers *int64 `json:"numberOfOffers,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CollectionProperties. +func (c CollectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allSubscriptions", c.AllSubscriptions) + populate(objectMap, "claim", c.Claim) + populate(objectMap, "collectionId", c.CollectionID) + populate(objectMap, "collectionName", c.CollectionName) + populate(objectMap, "enabled", c.Enabled) + populate(objectMap, "numberOfOffers", c.NumberOfOffers) + populate(objectMap, "subscriptionsList", c.SubscriptionsList) + return json.Marshal(objectMap) +} + +// CollectionsDetails - Collection name and id. +type CollectionsDetails struct { + // Collection id. + CollectionID *string `json:"collectionId,omitempty"` + + // Collection name. + CollectionName *string `json:"collectionName,omitempty"` +} + +type CollectionsList struct { + // URL to get the next set of offer list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + Value []*Collection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CollectionsList. +func (c CollectionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CollectionsSubscriptionsMappingDetails - Collection name and related subscriptions list +type CollectionsSubscriptionsMappingDetails struct { + // Collection name + CollectionName *string `json:"collectionName,omitempty"` + + // Subscriptions ids list + Subscriptions []*string `json:"subscriptions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CollectionsSubscriptionsMappingDetails. +func (c CollectionsSubscriptionsMappingDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "collectionName", c.CollectionName) + populate(objectMap, "subscriptions", c.Subscriptions) + return json.Marshal(objectMap) +} + +// CollectionsToSubscriptionsMappingPayload - The subscriptions list to get the related collections +type CollectionsToSubscriptionsMappingPayload struct { + // Subscriptions ids list + Properties *CollectionsToSubscriptionsMappingProperties `json:"properties,omitempty"` +} + +// CollectionsToSubscriptionsMappingProperties - The subscriptions list to get the related collections +type CollectionsToSubscriptionsMappingProperties struct { + // Subscriptions ids list + SubscriptionIDs []*string `json:"subscriptionIds,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CollectionsToSubscriptionsMappingProperties. +func (c CollectionsToSubscriptionsMappingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "subscriptionIds", c.SubscriptionIDs) + return json.Marshal(objectMap) +} + +// CollectionsToSubscriptionsMappingResponse - A map of collections subscriptions details +type CollectionsToSubscriptionsMappingResponse struct { + // The map of collections subscriptions + Details map[string]*CollectionsSubscriptionsMappingDetails `json:"details,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CollectionsToSubscriptionsMappingResponse. +func (c CollectionsToSubscriptionsMappingResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "details", c.Details) + return json.Marshal(objectMap) +} + +// ErrorResponse - Error response indicates Microsoft.Marketplace service is not able to process the incoming request. The reason is provided in the error +// message. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The details of the error. + InnerError *ErrorResponseError `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ErrorResponseError - The details of the error. +type ErrorResponseError struct { + // READ-ONLY; Error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// NewNotifications - New plans notification details +type NewNotifications struct { + // Gets offer display name + DisplayName *string `json:"displayName,omitempty"` + + // Gets or sets the icon url + Icon *string `json:"icon,omitempty"` + + // Gets a value indicating whether future plans is enabled. + IsFuturePlansEnabled *bool `json:"isFuturePlansEnabled,omitempty"` + + // Gets or sets the notification message id + MessageCode *int64 `json:"messageCode,omitempty"` + + // Gets offer id + OfferID *string `json:"offerId,omitempty"` + + // Gets or sets removed plans notifications + Plans []*PlanNotificationDetails `json:"plans,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NewNotifications. +func (n NewNotifications) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "icon", n.Icon) + populate(objectMap, "isFuturePlansEnabled", n.IsFuturePlansEnabled) + populate(objectMap, "messageCode", n.MessageCode) + populate(objectMap, "offerId", n.OfferID) + populate(objectMap, "plans", n.Plans) + return json.Marshal(objectMap) +} + +// NotificationsSettingsProperties - Describes the json payload for notifications settings +type NotificationsSettingsProperties struct { + // Gets or sets list of notified recipients for new requests + Recipients []*Recipient `json:"recipients,omitempty"` + + // Gets or sets whether to send email to all marketplace admins for new requests + SendToAllMarketplaceAdmins *bool `json:"sendToAllMarketplaceAdmins,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationsSettingsProperties. +func (n NotificationsSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "recipients", n.Recipients) + populate(objectMap, "sendToAllMarketplaceAdmins", n.SendToAllMarketplaceAdmins) + return json.Marshal(objectMap) +} + +// Offer - The privateStore offer data structure. +type Offer struct { + Resource + // The privateStore offer data structure. + Properties *OfferProperties `json:"properties,omitempty"` +} + +type OfferListResponse struct { + // URL to get the next set of offer list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + Value []*Offer `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OfferListResponse. +func (o OfferListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +type OfferProperties struct { + // Identifier for purposes of race condition + ETag *string `json:"eTag,omitempty"` + + // Icon File Uris + IconFileUris map[string]*string `json:"iconFileUris,omitempty"` + + // Offer plans + Plans []*Plan `json:"plans,omitempty"` + + // Plan ids limitation for this offer + SpecificPlanIDsLimitation []*string `json:"specificPlanIdsLimitation,omitempty"` + + // Indicating whether the offer was not updated to db (true = not updated). If the allow list is identical to the existed one in db, the offer would not + // be updated. + UpdateSuppressedDueIdempotence *bool `json:"updateSuppressedDueIdempotence,omitempty"` + + // READ-ONLY; Private store offer creation date + CreatedAt *string `json:"createdAt,omitempty" azure:"ro"` + + // READ-ONLY; Private store offer modification date + ModifiedAt *string `json:"modifiedAt,omitempty" azure:"ro"` + + // READ-ONLY; It will be displayed prominently in the marketplace + OfferDisplayName *string `json:"offerDisplayName,omitempty" azure:"ro"` + + // READ-ONLY; Private store unique id + PrivateStoreID *string `json:"privateStoreId,omitempty" azure:"ro"` + + // READ-ONLY; Publisher name that will be displayed prominently in the marketplace + PublisherDisplayName *string `json:"publisherDisplayName,omitempty" azure:"ro"` + + // READ-ONLY; Offers unique id + UniqueOfferID *string `json:"uniqueOfferId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OfferProperties. +func (o OfferProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", o.CreatedAt) + populate(objectMap, "eTag", o.ETag) + populate(objectMap, "iconFileUris", o.IconFileUris) + populate(objectMap, "modifiedAt", o.ModifiedAt) + populate(objectMap, "offerDisplayName", o.OfferDisplayName) + populate(objectMap, "plans", o.Plans) + populate(objectMap, "privateStoreId", o.PrivateStoreID) + populate(objectMap, "publisherDisplayName", o.PublisherDisplayName) + populate(objectMap, "specificPlanIdsLimitation", o.SpecificPlanIDsLimitation) + populate(objectMap, "uniqueOfferId", o.UniqueOfferID) + populate(objectMap, "updateSuppressedDueIdempotence", o.UpdateSuppressedDueIdempotence) + return json.Marshal(objectMap) +} + +// OperationListResult - Result of the request to list Marketplace operations. It contains a list of operations and a URL link to get the next set of results. +type OperationListResult struct { + // List of Microsoft.Marketplace operations supported by the Microsoft.Marketplace resource provider. + Value []*SingleOperation `json:"value,omitempty"` + + // READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +type Plan struct { + // Plan accessibility + Accessibility *Accessibility `json:"accessibility,omitempty"` + + // READ-ONLY; Alternative stack type + AltStackReference *string `json:"altStackReference,omitempty" azure:"ro"` + + // READ-ONLY; Friendly name for the plan for display in the marketplace + PlanDisplayName *string `json:"planDisplayName,omitempty" azure:"ro"` + + // READ-ONLY; Text identifier for this plan + PlanID *string `json:"planId,omitempty" azure:"ro"` + + // READ-ONLY; Identifier for this plan + SKUID *string `json:"skuId,omitempty" azure:"ro"` + + // READ-ONLY; Stack type (classic or arm) + StackType *string `json:"stackType,omitempty" azure:"ro"` +} + +// PlanDetails - Return plan with request details +type PlanDetails struct { + // Gets or sets user's justification for the plan's request + Justification *string `json:"justification,omitempty"` + + // Gets or sets Plan Id + PlanID *string `json:"planId,omitempty"` + + // Gets or sets the subscription id that the user is requesting to add the plan to + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // Gets or sets the subscription name that the user is requesting to add the plan to + SubscriptionName *string `json:"subscriptionName,omitempty"` + + // READ-ONLY; Gets request date + RequestDate interface{} `json:"requestDate,omitempty" azure:"ro"` + + // READ-ONLY; Gets the plan status + Status *Status `json:"status,omitempty" azure:"ro"` +} + +// PlanNotificationDetails - Plan notification details +type PlanNotificationDetails struct { + // Gets or sets the plan display name + PlanDisplayName *string `json:"planDisplayName,omitempty"` + + // Gets or sets the plan id + PlanID *string `json:"planId,omitempty"` +} + +// PlanRequesterDetails - Plan with requesters details +type PlanRequesterDetails struct { + // READ-ONLY; Gets the plan display name + PlanDisplayName *string `json:"planDisplayName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the plan id + PlanID *string `json:"planId,omitempty" azure:"ro"` + + // READ-ONLY; Gets requesters details list + Requesters []*UserRequestDetails `json:"requesters,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PlanRequesterDetails. +func (p PlanRequesterDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "planDisplayName", p.PlanDisplayName) + populate(objectMap, "planId", p.PlanID) + populate(objectMap, "requesters", p.Requesters) + return json.Marshal(objectMap) +} + +// PrivateStore - The PrivateStore data structure. +type PrivateStore struct { + Resource + // The PrivateStore data structure. + Properties *PrivateStoreProperties `json:"properties,omitempty"` +} + +// PrivateStoreAcknowledgeOfferNotificationOptions contains the optional parameters for the PrivateStore.AcknowledgeOfferNotification method. +type PrivateStoreAcknowledgeOfferNotificationOptions struct { + Payload *AcknowledgeOfferNotificationProperties +} + +// PrivateStoreAdminRequestApprovalsListOptions contains the optional parameters for the PrivateStore.AdminRequestApprovalsList method. +type PrivateStoreAdminRequestApprovalsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreBillingAccountsOptions contains the optional parameters for the PrivateStore.BillingAccounts method. +type PrivateStoreBillingAccountsOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreBulkCollectionsActionOptions contains the optional parameters for the PrivateStore.BulkCollectionsAction method. +type PrivateStoreBulkCollectionsActionOptions struct { + Payload *BulkCollectionsPayload +} + +// PrivateStoreCollectionCreateOrUpdateOptions contains the optional parameters for the PrivateStoreCollection.CreateOrUpdate method. +type PrivateStoreCollectionCreateOrUpdateOptions struct { + Payload *Collection +} + +// PrivateStoreCollectionDeleteOptions contains the optional parameters for the PrivateStoreCollection.Delete method. +type PrivateStoreCollectionDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionGetOptions contains the optional parameters for the PrivateStoreCollection.Get method. +type PrivateStoreCollectionGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionListOptions contains the optional parameters for the PrivateStoreCollection.List method. +type PrivateStoreCollectionListOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionOfferCreateOrUpdateOptions contains the optional parameters for the PrivateStoreCollectionOffer.CreateOrUpdate method. +type PrivateStoreCollectionOfferCreateOrUpdateOptions struct { + Payload *Offer +} + +// PrivateStoreCollectionOfferDeleteOptions contains the optional parameters for the PrivateStoreCollectionOffer.Delete method. +type PrivateStoreCollectionOfferDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionOfferGetOptions contains the optional parameters for the PrivateStoreCollectionOffer.Get method. +type PrivateStoreCollectionOfferGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionOfferListOptions contains the optional parameters for the PrivateStoreCollectionOffer.List method. +type PrivateStoreCollectionOfferListOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreCollectionOfferPostOptions contains the optional parameters for the PrivateStoreCollectionOffer.Post method. +type PrivateStoreCollectionOfferPostOptions struct { + Payload *Operation +} + +// PrivateStoreCollectionPostOptions contains the optional parameters for the PrivateStoreCollection.Post method. +type PrivateStoreCollectionPostOptions struct { + Payload *Operation +} + +// PrivateStoreCollectionTransferOffersOptions contains the optional parameters for the PrivateStoreCollection.TransferOffers method. +type PrivateStoreCollectionTransferOffersOptions struct { + Payload *TransferOffersProperties +} + +// PrivateStoreCollectionsToSubscriptionsMappingOptions contains the optional parameters for the PrivateStore.CollectionsToSubscriptionsMapping method. +type PrivateStoreCollectionsToSubscriptionsMappingOptions struct { + Payload *CollectionsToSubscriptionsMappingPayload +} + +// PrivateStoreCreateApprovalRequestOptions contains the optional parameters for the PrivateStore.CreateApprovalRequest method. +type PrivateStoreCreateApprovalRequestOptions struct { + Payload *RequestApprovalResource +} + +// PrivateStoreCreateOrUpdateOptions contains the optional parameters for the PrivateStore.CreateOrUpdate method. +type PrivateStoreCreateOrUpdateOptions struct { + Payload *PrivateStore +} + +// PrivateStoreDeleteOptions contains the optional parameters for the PrivateStore.Delete method. +type PrivateStoreDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreGetAdminRequestApprovalOptions contains the optional parameters for the PrivateStore.GetAdminRequestApproval method. +type PrivateStoreGetAdminRequestApprovalOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreGetApprovalRequestsListOptions contains the optional parameters for the PrivateStore.GetApprovalRequestsList method. +type PrivateStoreGetApprovalRequestsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreGetOptions contains the optional parameters for the PrivateStore.Get method. +type PrivateStoreGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreGetRequestApprovalOptions contains the optional parameters for the PrivateStore.GetRequestApproval method. +type PrivateStoreGetRequestApprovalOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreList - Describes the json payload for the list of available private stores (between zero and one, inclusive) +type PrivateStoreList struct { + // URL to get the next set of PrivateStore list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + Value []*PrivateStore `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateStoreList. +func (p PrivateStoreList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateStoreListOptions contains the optional parameters for the PrivateStore.List method. +type PrivateStoreListOptions struct { + // Determines if to use cache or DB for serving this request + UseCache *string +} + +// PrivateStoreNotificationsState - Get private store notifications state +type PrivateStoreNotificationsState struct { + ApprovalRequests []*RequestApprovalsDetails `json:"approvalRequests,omitempty"` + NewNotifications []*NewNotifications `json:"newNotifications,omitempty"` + StopSellNotifications []*StopSellNotifications `json:"stopSellNotifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateStoreNotificationsState. +func (p PrivateStoreNotificationsState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "approvalRequests", p.ApprovalRequests) + populate(objectMap, "newNotifications", p.NewNotifications) + populate(objectMap, "stopSellNotifications", p.StopSellNotifications) + return json.Marshal(objectMap) +} + +// PrivateStoreProperties - Describes the json payload on whether or not the private store is enabled for a given tenant +type PrivateStoreProperties struct { + // Indicates private store availability + Availability *Availability `json:"availability,omitempty"` + + // Gets or sets list of branding characteristics + Branding map[string]*string `json:"branding,omitempty"` + + // Identifier for purposes of race condition + ETag *string `json:"eTag,omitempty"` + + // Is government + IsGov *bool `json:"isGov,omitempty"` + + // Gets or sets notifications settings + NotificationsSettings *NotificationsSettingsProperties `json:"notificationsSettings,omitempty"` + + // Private Store Name + PrivateStoreName *string `json:"privateStoreName,omitempty"` + + // Tenant id + TenantID *string `json:"tenantId,omitempty"` + + // READ-ONLY; Gets list of associated collection ids + CollectionIDs []*string `json:"collectionIds,omitempty" azure:"ro"` + + // READ-ONLY; Private Store id + PrivateStoreID *string `json:"privateStoreId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateStoreProperties. +func (p PrivateStoreProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availability", p.Availability) + populate(objectMap, "branding", p.Branding) + populate(objectMap, "collectionIds", p.CollectionIDs) + populate(objectMap, "eTag", p.ETag) + populate(objectMap, "isGov", p.IsGov) + populate(objectMap, "notificationsSettings", p.NotificationsSettings) + populate(objectMap, "privateStoreId", p.PrivateStoreID) + populate(objectMap, "privateStoreName", p.PrivateStoreName) + populate(objectMap, "tenantId", p.TenantID) + return json.Marshal(objectMap) +} + +// PrivateStoreQueryApprovedPlansOptions contains the optional parameters for the PrivateStore.QueryApprovedPlans method. +type PrivateStoreQueryApprovedPlansOptions struct { + Payload *QueryApprovedPlansPayload +} + +// PrivateStoreQueryNotificationsStateOptions contains the optional parameters for the PrivateStore.QueryNotificationsState method. +type PrivateStoreQueryNotificationsStateOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreQueryOffersOptions contains the optional parameters for the PrivateStore.QueryOffers method. +type PrivateStoreQueryOffersOptions struct { + // placeholder for future optional parameters +} + +// PrivateStoreQueryRequestApprovalOptions contains the optional parameters for the PrivateStore.QueryRequestApproval method. +type PrivateStoreQueryRequestApprovalOptions struct { + Payload *QueryRequestApprovalProperties +} + +// PrivateStoreUpdateAdminRequestApprovalOptions contains the optional parameters for the PrivateStore.UpdateAdminRequestApproval method. +type PrivateStoreUpdateAdminRequestApprovalOptions struct { + Payload *AdminRequestApprovalsResource +} + +// PrivateStoreWithdrawPlanOptions contains the optional parameters for the PrivateStore.WithdrawPlan method. +type PrivateStoreWithdrawPlanOptions struct { + Payload *WithdrawProperties +} + +// QueryApprovedPlans - Query approved plans details +type QueryApprovedPlans struct { + // Offer id + OfferID *string `json:"offerId,omitempty"` + + // Offer plan ids + PlanIDs []*string `json:"planIds,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QueryApprovedPlans. +func (q QueryApprovedPlans) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "offerId", q.OfferID) + populate(objectMap, "planIds", q.PlanIDs) + return json.Marshal(objectMap) +} + +// QueryApprovedPlansDetails - Query approved plans response +type QueryApprovedPlansDetails struct { + // Indicates whether all subscriptions are approved for this plan + AllSubscriptions *bool `json:"allSubscriptions,omitempty"` + + // Plan id + PlanID *string `json:"planId,omitempty"` + + // Approved subscription ids list. In case all subscriptions are approved for a plan, allSubscriptions flag is true and list is empty ( else flag is set + // to false). In case both subscriptions list is + // empty and allSubscriptions flag is false, the plan is not approved for any subscription. + SubscriptionIDs []*string `json:"subscriptionIds,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QueryApprovedPlansDetails. +func (q QueryApprovedPlansDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allSubscriptions", q.AllSubscriptions) + populate(objectMap, "planId", q.PlanID) + populate(objectMap, "subscriptionIds", q.SubscriptionIDs) + return json.Marshal(objectMap) +} + +// QueryApprovedPlansPayload - Query approved plans payload +type QueryApprovedPlansPayload struct { + // Query approved plans details + Properties *QueryApprovedPlans `json:"properties,omitempty"` +} + +// QueryApprovedPlansResponse - Query approved plans response +type QueryApprovedPlansResponse struct { + // A list indicating for each plan which subscriptions are approved. Plan Id is unique + Details []*QueryApprovedPlansDetails `json:"details,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QueryApprovedPlansResponse. +func (q QueryApprovedPlansResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "details", q.Details) + return json.Marshal(objectMap) +} + +// QueryOffers - List of offers +type QueryOffers struct { + // URL to get the next set of PrivateStore list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + Value []*OfferProperties `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QueryOffers. +func (q QueryOffers) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// QueryRequestApproval - Gets the request plans with indication on each plan whether is approved by the admin, has pending request or not requested yet +type QueryRequestApproval struct { + // Gets or sets e-tag field + Etag *string `json:"etag,omitempty"` + + // Gets or sets the notification message id + MessageCode *int64 `json:"messageCode,omitempty"` + + // Gets or sets the plans details + PlansDetails map[string]*PlanDetails `json:"plansDetails,omitempty"` + + // Gets or sets unique offer id. + UniqueOfferID *string `json:"uniqueOfferId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QueryRequestApproval. +func (q QueryRequestApproval) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", q.Etag) + populate(objectMap, "messageCode", q.MessageCode) + populate(objectMap, "plansDetails", q.PlansDetails) + populate(objectMap, "uniqueOfferId", q.UniqueOfferID) + return json.Marshal(objectMap) +} + +// QueryRequestApprovalProperties - The details to get the request plans statuses +type QueryRequestApprovalProperties struct { + // The details to get the request plans statuses + Properties *RequestDetails `json:"properties,omitempty"` +} + +// Recipient - Describes the json payload for a notified recipient for new requests +type Recipient struct { + // Principal ID + PrincipalID *string `json:"principalId,omitempty"` + + // READ-ONLY; Display Name + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Email Address + EmailAddress *string `json:"emailAddress,omitempty" azure:"ro"` +} + +// RequestApprovalProperties - Approval request resource properties +type RequestApprovalProperties struct { + // Gets or sets the request approval message code + MessageCode *int64 `json:"messageCode,omitempty"` + + // Gets or sets unique offer id. + OfferID *string `json:"offerId,omitempty"` + + // Gets or sets the plans details + PlansDetails []*PlanDetails `json:"plansDetails,omitempty"` + + // The offer's publisher id + PublisherID *string `json:"publisherId,omitempty"` + + // READ-ONLY; Gets a value indicating whether the request is closed + IsClosed *bool `json:"isClosed,omitempty" azure:"ro"` + + // READ-ONLY; Gets offer display name + OfferDisplayName *string `json:"offerDisplayName,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestApprovalProperties. +func (r RequestApprovalProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "isClosed", r.IsClosed) + populate(objectMap, "messageCode", r.MessageCode) + populate(objectMap, "offerDisplayName", r.OfferDisplayName) + populate(objectMap, "offerId", r.OfferID) + populate(objectMap, "plansDetails", r.PlansDetails) + populate(objectMap, "publisherId", r.PublisherID) + return json.Marshal(objectMap) +} + +// RequestApprovalResource - Request approval resource. +type RequestApprovalResource struct { + Resource + // The privateStore approval request data structure. + Properties *RequestApprovalProperties `json:"properties,omitempty"` +} + +// RequestApprovalsDetails - Request approvals details +type RequestApprovalsDetails struct { + // Gets offer display name + DisplayName *string `json:"displayName,omitempty"` + + // Gets or sets the icon url + Icon *string `json:"icon,omitempty"` + + // Gets or sets the notification message id + MessageCode *int64 `json:"messageCode,omitempty"` + + // Gets offer id + OfferID *string `json:"offerId,omitempty"` + + // Gets or sets removed plans notifications + Plans []*PlanNotificationDetails `json:"plans,omitempty"` + + // Gets or sets publisher id + PublisherID *string `json:"publisherId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestApprovalsDetails. +func (r RequestApprovalsDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", r.DisplayName) + populate(objectMap, "icon", r.Icon) + populate(objectMap, "messageCode", r.MessageCode) + populate(objectMap, "offerId", r.OfferID) + populate(objectMap, "plans", r.Plans) + populate(objectMap, "publisherId", r.PublisherID) + return json.Marshal(objectMap) +} + +// RequestApprovalsList - List of admin request approval resources +type RequestApprovalsList struct { + Value []*RequestApprovalResource `json:"value,omitempty"` + + // READ-ONLY; URL to get the next set of notifications list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestApprovalsList. +func (r RequestApprovalsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RequestDetails - Request details needed to get the plans statuses +type RequestDetails struct { + // Current plans list + PlanIDs []*string `json:"planIds,omitempty"` + + // The offer's publisher id + PublisherID *string `json:"publisherId,omitempty"` + + // Gets or sets the subscription id + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestDetails. +func (r RequestDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "planIds", r.PlanIDs) + populate(objectMap, "publisherId", r.PublisherID) + populate(objectMap, "subscriptionId", r.SubscriptionID) + return json.Marshal(objectMap) +} + +// Resource - An Azure resource. +type Resource struct { + // READ-ONLY; The resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SingleOperation - Microsoft.Marketplace REST API operation +type SingleOperation struct { + // The object that represents the operation. + Display *SingleOperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + + // Origin of the operation + Origin *string `json:"origin,omitempty"` + + // Properties of the operation + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// SingleOperationDisplay - The object that represents the operation. +type SingleOperationDisplay struct { + // READ-ONLY; Friendly description for the operation, + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Operation type + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Service provider: Microsoft.Marketplace + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Resource on which the operation is performed + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// StopSellNotifications - Stop sell notification details +type StopSellNotifications struct { + // Gets offer display name + DisplayName *string `json:"displayName,omitempty"` + + // Gets or sets the icon url + Icon *string `json:"icon,omitempty"` + + // Gets a value indicating whether entire offer is in stop sell or only few of its plans + IsEntire *bool `json:"isEntire,omitempty"` + + // Gets or sets the notification message id + MessageCode *int64 `json:"messageCode,omitempty"` + + // Gets offer id + OfferID *string `json:"offerId,omitempty"` + + // Gets or sets removed plans notifications + Plans []*PlanNotificationDetails `json:"plans,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StopSellNotifications. +func (s StopSellNotifications) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "icon", s.Icon) + populate(objectMap, "isEntire", s.IsEntire) + populate(objectMap, "messageCode", s.MessageCode) + populate(objectMap, "offerId", s.OfferID) + populate(objectMap, "plans", s.Plans) + return json.Marshal(objectMap) +} + +// SystemData - Read only system data +type SystemData struct { + // The timestamp of resource creation (UTC) + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource + CreatedByType *IdentityType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource + LastModifiedByType *IdentityType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TransferOffersDetails - Transfer offers response details +type TransferOffersDetails struct { + // Offers ids list to transfer from source collection to target collection(s) + OfferIDsList []*string `json:"offerIdsList,omitempty"` + + // Operation to perform (For example: Copy or Move) + Operation *string `json:"operation,omitempty"` + + // Target collections ids + TargetCollections []*string `json:"targetCollections,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TransferOffersDetails. +func (t TransferOffersDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "offerIdsList", t.OfferIDsList) + populate(objectMap, "operation", t.Operation) + populate(objectMap, "targetCollections", t.TargetCollections) + return json.Marshal(objectMap) +} + +// TransferOffersProperties - Transfer offers properties +type TransferOffersProperties struct { + // transfer offers properties details + Properties *TransferOffersDetails `json:"properties,omitempty"` +} + +// TransferOffersResponse - The transfer items response. The response contains two lists that indicate for each collection whether the operation succeeded +// or failed +type TransferOffersResponse struct { + // Failed collections + Failed []*CollectionsDetails `json:"failed,omitempty"` + + // Succeeded collections + Succeeded []*CollectionsDetails `json:"succeeded,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TransferOffersResponse. +func (t TransferOffersResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "failed", t.Failed) + populate(objectMap, "succeeded", t.Succeeded) + return json.Marshal(objectMap) +} + +// UserRequestDetails - user request details +type UserRequestDetails struct { + // Gets the subscription id that the user is requesting to add the plan to + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // Gets the subscription name that the user is requesting to add the plan to + SubscriptionName *string `json:"subscriptionName,omitempty"` + + // READ-ONLY; Gets request date + Date *string `json:"date,omitempty" azure:"ro"` + + // READ-ONLY; Gets justification + Justification *string `json:"justification,omitempty" azure:"ro"` + + // READ-ONLY; Gets user id + User *string `json:"user,omitempty" azure:"ro"` +} + +// WithdrawDetails - Withdraw properties details +type WithdrawDetails struct { + // Gets or sets Plan Id + PlanID *string `json:"planId,omitempty"` + + // The offer's publisher id + PublisherID *string `json:"publisherId,omitempty"` +} + +// WithdrawProperties - Withdraw properties +type WithdrawProperties struct { + // Withdraw properties details + Properties *WithdrawDetails `json:"properties,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + 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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_operations_client.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_operations_client.go new file mode 100644 index 000000000000..df2d1ffa5c7c --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "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 { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available Microsoft.Marketplace REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_pagers.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_pagers.go new file mode 100644 index 000000000000..f7da3f889164 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_pagers.go @@ -0,0 +1,125 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// PrivateStoreCollectionOfferListPager provides operations for iterating over paged responses. +type PrivateStoreCollectionOfferListPager struct { + client *PrivateStoreCollectionOfferClient + current PrivateStoreCollectionOfferListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateStoreCollectionOfferListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateStoreCollectionOfferListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PrivateStoreCollectionOfferListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OfferListResponse.NextLink == nil || len(*p.current.OfferListResponse.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrivateStoreCollectionOfferListResponse page. +func (p *PrivateStoreCollectionOfferListPager) PageResponse() PrivateStoreCollectionOfferListResponse { + return p.current +} + +// PrivateStoreListPager provides operations for iterating over paged responses. +type PrivateStoreListPager struct { + client *PrivateStoreClient + current PrivateStoreListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrivateStoreListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrivateStoreListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PrivateStoreListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateStoreList.NextLink == nil || len(*p.current.PrivateStoreList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrivateStoreListResponse page. +func (p *PrivateStoreListPager) PageResponse() PrivateStoreListResponse { + return p.current +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestore_client.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestore_client.go new file mode 100644 index 000000000000..9d8b48346bbf --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestore_client.go @@ -0,0 +1,1142 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrivateStoreClient contains the methods for the PrivateStore group. +// Don't use this type directly, use NewPrivateStoreClient() instead. +type PrivateStoreClient struct { + ep string + pl runtime.Pipeline +} + +// NewPrivateStoreClient creates a new instance of PrivateStoreClient with the specified values. +func NewPrivateStoreClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateStoreClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateStoreClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// AcknowledgeOfferNotification - Acknowledge notification for offer +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) AcknowledgeOfferNotification(ctx context.Context, privateStoreID string, offerID string, options *PrivateStoreAcknowledgeOfferNotificationOptions) (PrivateStoreAcknowledgeOfferNotificationResponse, error) { + req, err := client.acknowledgeOfferNotificationCreateRequest(ctx, privateStoreID, offerID, options) + if err != nil { + return PrivateStoreAcknowledgeOfferNotificationResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreAcknowledgeOfferNotificationResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreAcknowledgeOfferNotificationResponse{}, client.acknowledgeOfferNotificationHandleError(resp) + } + return PrivateStoreAcknowledgeOfferNotificationResponse{RawResponse: resp}, nil +} + +// acknowledgeOfferNotificationCreateRequest creates the AcknowledgeOfferNotification request. +func (client *PrivateStoreClient) acknowledgeOfferNotificationCreateRequest(ctx context.Context, privateStoreID string, offerID string, options *PrivateStoreAcknowledgeOfferNotificationOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/offers/{offerId}/acknowledgeNotification" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + 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.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// acknowledgeOfferNotificationHandleError handles the AcknowledgeOfferNotification error response. +func (client *PrivateStoreClient) acknowledgeOfferNotificationHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// AdminRequestApprovalsList - Get list of admin request approvals +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) AdminRequestApprovalsList(ctx context.Context, privateStoreID string, options *PrivateStoreAdminRequestApprovalsListOptions) (PrivateStoreAdminRequestApprovalsListResponse, error) { + req, err := client.adminRequestApprovalsListCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreAdminRequestApprovalsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreAdminRequestApprovalsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreAdminRequestApprovalsListResponse{}, client.adminRequestApprovalsListHandleError(resp) + } + return client.adminRequestApprovalsListHandleResponse(resp) +} + +// adminRequestApprovalsListCreateRequest creates the AdminRequestApprovalsList request. +func (client *PrivateStoreClient) adminRequestApprovalsListCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreAdminRequestApprovalsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/adminRequestApprovals" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// adminRequestApprovalsListHandleResponse handles the AdminRequestApprovalsList response. +func (client *PrivateStoreClient) adminRequestApprovalsListHandleResponse(resp *http.Response) (PrivateStoreAdminRequestApprovalsListResponse, error) { + result := PrivateStoreAdminRequestApprovalsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AdminRequestApprovalsList); err != nil { + return PrivateStoreAdminRequestApprovalsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// adminRequestApprovalsListHandleError handles the AdminRequestApprovalsList error response. +func (client *PrivateStoreClient) adminRequestApprovalsListHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BillingAccounts - Tenant billing accounts names +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) BillingAccounts(ctx context.Context, privateStoreID string, options *PrivateStoreBillingAccountsOptions) (PrivateStoreBillingAccountsResponse, error) { + req, err := client.billingAccountsCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreBillingAccountsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreBillingAccountsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreBillingAccountsResponse{}, client.billingAccountsHandleError(resp) + } + return client.billingAccountsHandleResponse(resp) +} + +// billingAccountsCreateRequest creates the BillingAccounts request. +func (client *PrivateStoreClient) billingAccountsCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreBillingAccountsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/billingAccounts" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// billingAccountsHandleResponse handles the BillingAccounts response. +func (client *PrivateStoreClient) billingAccountsHandleResponse(resp *http.Response) (PrivateStoreBillingAccountsResponse, error) { + result := PrivateStoreBillingAccountsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.BillingAccountsResponse); err != nil { + return PrivateStoreBillingAccountsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// billingAccountsHandleError handles the BillingAccounts error response. +func (client *PrivateStoreClient) billingAccountsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BulkCollectionsAction - Perform an action on bulk collections +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) BulkCollectionsAction(ctx context.Context, privateStoreID string, options *PrivateStoreBulkCollectionsActionOptions) (PrivateStoreBulkCollectionsActionResponse, error) { + req, err := client.bulkCollectionsActionCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreBulkCollectionsActionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreBulkCollectionsActionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreBulkCollectionsActionResponse{}, client.bulkCollectionsActionHandleError(resp) + } + return client.bulkCollectionsActionHandleResponse(resp) +} + +// bulkCollectionsActionCreateRequest creates the BulkCollectionsAction request. +func (client *PrivateStoreClient) bulkCollectionsActionCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreBulkCollectionsActionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/bulkCollectionsAction" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// bulkCollectionsActionHandleResponse handles the BulkCollectionsAction response. +func (client *PrivateStoreClient) bulkCollectionsActionHandleResponse(resp *http.Response) (PrivateStoreBulkCollectionsActionResponse, error) { + result := PrivateStoreBulkCollectionsActionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.BulkCollectionsResponse); err != nil { + return PrivateStoreBulkCollectionsActionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// bulkCollectionsActionHandleError handles the BulkCollectionsAction error response. +func (client *PrivateStoreClient) bulkCollectionsActionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// CollectionsToSubscriptionsMapping - For a given subscriptions list, the API will return a map of collections and the related subscriptions from the supplied +// list. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) CollectionsToSubscriptionsMapping(ctx context.Context, privateStoreID string, options *PrivateStoreCollectionsToSubscriptionsMappingOptions) (PrivateStoreCollectionsToSubscriptionsMappingResponse, error) { + req, err := client.collectionsToSubscriptionsMappingCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreCollectionsToSubscriptionsMappingResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionsToSubscriptionsMappingResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionsToSubscriptionsMappingResponse{}, client.collectionsToSubscriptionsMappingHandleError(resp) + } + return client.collectionsToSubscriptionsMappingHandleResponse(resp) +} + +// collectionsToSubscriptionsMappingCreateRequest creates the CollectionsToSubscriptionsMapping request. +func (client *PrivateStoreClient) collectionsToSubscriptionsMappingCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreCollectionsToSubscriptionsMappingOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collectionsToSubscriptionsMapping" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// collectionsToSubscriptionsMappingHandleResponse handles the CollectionsToSubscriptionsMapping response. +func (client *PrivateStoreClient) collectionsToSubscriptionsMappingHandleResponse(resp *http.Response) (PrivateStoreCollectionsToSubscriptionsMappingResponse, error) { + result := PrivateStoreCollectionsToSubscriptionsMappingResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CollectionsToSubscriptionsMappingResponse); err != nil { + return PrivateStoreCollectionsToSubscriptionsMappingResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// collectionsToSubscriptionsMappingHandleError handles the CollectionsToSubscriptionsMapping error response. +func (client *PrivateStoreClient) collectionsToSubscriptionsMappingHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// CreateApprovalRequest - Create approval request +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) CreateApprovalRequest(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreCreateApprovalRequestOptions) (PrivateStoreCreateApprovalRequestResponse, error) { + req, err := client.createApprovalRequestCreateRequest(ctx, privateStoreID, requestApprovalID, options) + if err != nil { + return PrivateStoreCreateApprovalRequestResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCreateApprovalRequestResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCreateApprovalRequestResponse{}, client.createApprovalRequestHandleError(resp) + } + return client.createApprovalRequestHandleResponse(resp) +} + +// createApprovalRequestCreateRequest creates the CreateApprovalRequest request. +func (client *PrivateStoreClient) createApprovalRequestCreateRequest(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreCreateApprovalRequestOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/requestApprovals/{requestApprovalId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if requestApprovalID == "" { + return nil, errors.New("parameter requestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{requestApprovalId}", url.PathEscape(requestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// createApprovalRequestHandleResponse handles the CreateApprovalRequest response. +func (client *PrivateStoreClient) createApprovalRequestHandleResponse(resp *http.Response) (PrivateStoreCreateApprovalRequestResponse, error) { + result := PrivateStoreCreateApprovalRequestResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestApprovalResource); err != nil { + return PrivateStoreCreateApprovalRequestResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createApprovalRequestHandleError handles the CreateApprovalRequest error response. +func (client *PrivateStoreClient) createApprovalRequestHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// CreateOrUpdate - Changes private store properties +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) CreateOrUpdate(ctx context.Context, privateStoreID string, options *PrivateStoreCreateOrUpdateOptions) (PrivateStoreCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return PrivateStoreCreateOrUpdateResponse{RawResponse: resp}, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateStoreClient) createOrUpdateCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateStoreClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes the private store. All that is not saved will be lost. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) Delete(ctx context.Context, privateStoreID string, options *PrivateStoreDeleteOptions) (PrivateStoreDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PrivateStoreDeleteResponse{}, client.deleteHandleError(resp) + } + return PrivateStoreDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateStoreClient) deleteCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateStoreClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get information about the private store +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) Get(ctx context.Context, privateStoreID string, options *PrivateStoreGetOptions) (PrivateStoreGetResponse, error) { + req, err := client.getCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateStoreClient) getCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateStoreClient) getHandleResponse(resp *http.Response) (PrivateStoreGetResponse, error) { + result := PrivateStoreGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateStore); err != nil { + return PrivateStoreGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateStoreClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// GetAdminRequestApproval - Get open approval requests +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) GetAdminRequestApproval(ctx context.Context, privateStoreID string, adminRequestApprovalID string, publisherID string, options *PrivateStoreGetAdminRequestApprovalOptions) (PrivateStoreGetAdminRequestApprovalResponse, error) { + req, err := client.getAdminRequestApprovalCreateRequest(ctx, privateStoreID, adminRequestApprovalID, publisherID, options) + if err != nil { + return PrivateStoreGetAdminRequestApprovalResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreGetAdminRequestApprovalResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreGetAdminRequestApprovalResponse{}, client.getAdminRequestApprovalHandleError(resp) + } + return client.getAdminRequestApprovalHandleResponse(resp) +} + +// getAdminRequestApprovalCreateRequest creates the GetAdminRequestApproval request. +func (client *PrivateStoreClient) getAdminRequestApprovalCreateRequest(ctx context.Context, privateStoreID string, adminRequestApprovalID string, publisherID string, options *PrivateStoreGetAdminRequestApprovalOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/adminRequestApprovals/{adminRequestApprovalId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if adminRequestApprovalID == "" { + return nil, errors.New("parameter adminRequestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{adminRequestApprovalId}", url.PathEscape(adminRequestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + reqQP.Set("publisherId", publisherID) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getAdminRequestApprovalHandleResponse handles the GetAdminRequestApproval response. +func (client *PrivateStoreClient) getAdminRequestApprovalHandleResponse(resp *http.Response) (PrivateStoreGetAdminRequestApprovalResponse, error) { + result := PrivateStoreGetAdminRequestApprovalResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AdminRequestApprovalsResource); err != nil { + return PrivateStoreGetAdminRequestApprovalResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getAdminRequestApprovalHandleError handles the GetAdminRequestApproval error response. +func (client *PrivateStoreClient) getAdminRequestApprovalHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// GetApprovalRequestsList - Get all open approval requests of current user +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) GetApprovalRequestsList(ctx context.Context, privateStoreID string, options *PrivateStoreGetApprovalRequestsListOptions) (PrivateStoreGetApprovalRequestsListResponse, error) { + req, err := client.getApprovalRequestsListCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreGetApprovalRequestsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreGetApprovalRequestsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreGetApprovalRequestsListResponse{}, client.getApprovalRequestsListHandleError(resp) + } + return client.getApprovalRequestsListHandleResponse(resp) +} + +// getApprovalRequestsListCreateRequest creates the GetApprovalRequestsList request. +func (client *PrivateStoreClient) getApprovalRequestsListCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreGetApprovalRequestsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/requestApprovals" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getApprovalRequestsListHandleResponse handles the GetApprovalRequestsList response. +func (client *PrivateStoreClient) getApprovalRequestsListHandleResponse(resp *http.Response) (PrivateStoreGetApprovalRequestsListResponse, error) { + result := PrivateStoreGetApprovalRequestsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestApprovalsList); err != nil { + return PrivateStoreGetApprovalRequestsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getApprovalRequestsListHandleError handles the GetApprovalRequestsList error response. +func (client *PrivateStoreClient) getApprovalRequestsListHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// GetRequestApproval - Get open request approval details +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) GetRequestApproval(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreGetRequestApprovalOptions) (PrivateStoreGetRequestApprovalResponse, error) { + req, err := client.getRequestApprovalCreateRequest(ctx, privateStoreID, requestApprovalID, options) + if err != nil { + return PrivateStoreGetRequestApprovalResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreGetRequestApprovalResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreGetRequestApprovalResponse{}, client.getRequestApprovalHandleError(resp) + } + return client.getRequestApprovalHandleResponse(resp) +} + +// getRequestApprovalCreateRequest creates the GetRequestApproval request. +func (client *PrivateStoreClient) getRequestApprovalCreateRequest(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreGetRequestApprovalOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/requestApprovals/{requestApprovalId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if requestApprovalID == "" { + return nil, errors.New("parameter requestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{requestApprovalId}", url.PathEscape(requestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getRequestApprovalHandleResponse handles the GetRequestApproval response. +func (client *PrivateStoreClient) getRequestApprovalHandleResponse(resp *http.Response) (PrivateStoreGetRequestApprovalResponse, error) { + result := PrivateStoreGetRequestApprovalResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.RequestApprovalResource); err != nil { + return PrivateStoreGetRequestApprovalResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getRequestApprovalHandleError handles the GetRequestApproval error response. +func (client *PrivateStoreClient) getRequestApprovalHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets the list of available private stores. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) List(options *PrivateStoreListOptions) *PrivateStoreListPager { + return &PrivateStoreListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PrivateStoreListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PrivateStoreList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateStoreClient) listCreateRequest(ctx context.Context, options *PrivateStoreListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + if options != nil && options.UseCache != nil { + reqQP.Set("use-cache", *options.UseCache) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateStoreClient) listHandleResponse(resp *http.Response) (PrivateStoreListResponse, error) { + result := PrivateStoreListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateStoreList); err != nil { + return PrivateStoreListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateStoreClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// QueryApprovedPlans - Get map of plans and related approved subscriptions. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) QueryApprovedPlans(ctx context.Context, privateStoreID string, options *PrivateStoreQueryApprovedPlansOptions) (PrivateStoreQueryApprovedPlansResponse, error) { + req, err := client.queryApprovedPlansCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreQueryApprovedPlansResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreQueryApprovedPlansResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreQueryApprovedPlansResponse{}, client.queryApprovedPlansHandleError(resp) + } + return client.queryApprovedPlansHandleResponse(resp) +} + +// queryApprovedPlansCreateRequest creates the QueryApprovedPlans request. +func (client *PrivateStoreClient) queryApprovedPlansCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreQueryApprovedPlansOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/queryApprovedPlans" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// queryApprovedPlansHandleResponse handles the QueryApprovedPlans response. +func (client *PrivateStoreClient) queryApprovedPlansHandleResponse(resp *http.Response) (PrivateStoreQueryApprovedPlansResponse, error) { + result := PrivateStoreQueryApprovedPlansResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.QueryApprovedPlansResponse); err != nil { + return PrivateStoreQueryApprovedPlansResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// queryApprovedPlansHandleError handles the QueryApprovedPlans error response. +func (client *PrivateStoreClient) queryApprovedPlansHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// QueryNotificationsState - Get private store notifications state +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) QueryNotificationsState(ctx context.Context, privateStoreID string, options *PrivateStoreQueryNotificationsStateOptions) (PrivateStoreQueryNotificationsStateResponse, error) { + req, err := client.queryNotificationsStateCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreQueryNotificationsStateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreQueryNotificationsStateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreQueryNotificationsStateResponse{}, client.queryNotificationsStateHandleError(resp) + } + return client.queryNotificationsStateHandleResponse(resp) +} + +// queryNotificationsStateCreateRequest creates the QueryNotificationsState request. +func (client *PrivateStoreClient) queryNotificationsStateCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreQueryNotificationsStateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/queryNotificationsState" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// queryNotificationsStateHandleResponse handles the QueryNotificationsState response. +func (client *PrivateStoreClient) queryNotificationsStateHandleResponse(resp *http.Response) (PrivateStoreQueryNotificationsStateResponse, error) { + result := PrivateStoreQueryNotificationsStateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateStoreNotificationsState); err != nil { + return PrivateStoreQueryNotificationsStateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// queryNotificationsStateHandleError handles the QueryNotificationsState error response. +func (client *PrivateStoreClient) queryNotificationsStateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// QueryOffers - List of offers, regardless the collections +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) QueryOffers(ctx context.Context, privateStoreID string, options *PrivateStoreQueryOffersOptions) (PrivateStoreQueryOffersResponse, error) { + req, err := client.queryOffersCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreQueryOffersResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreQueryOffersResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreQueryOffersResponse{}, client.queryOffersHandleError(resp) + } + return client.queryOffersHandleResponse(resp) +} + +// queryOffersCreateRequest creates the QueryOffers request. +func (client *PrivateStoreClient) queryOffersCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreQueryOffersOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/queryOffers" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// queryOffersHandleResponse handles the QueryOffers response. +func (client *PrivateStoreClient) queryOffersHandleResponse(resp *http.Response) (PrivateStoreQueryOffersResponse, error) { + result := PrivateStoreQueryOffersResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.QueryOffers); err != nil { + return PrivateStoreQueryOffersResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// queryOffersHandleError handles the QueryOffers error response. +func (client *PrivateStoreClient) queryOffersHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// QueryRequestApproval - Get request statuses foreach plan, this api is used as a complex GET action. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) QueryRequestApproval(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreQueryRequestApprovalOptions) (PrivateStoreQueryRequestApprovalResponse, error) { + req, err := client.queryRequestApprovalCreateRequest(ctx, privateStoreID, requestApprovalID, options) + if err != nil { + return PrivateStoreQueryRequestApprovalResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreQueryRequestApprovalResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreQueryRequestApprovalResponse{}, client.queryRequestApprovalHandleError(resp) + } + return client.queryRequestApprovalHandleResponse(resp) +} + +// queryRequestApprovalCreateRequest creates the QueryRequestApproval request. +func (client *PrivateStoreClient) queryRequestApprovalCreateRequest(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreQueryRequestApprovalOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/requestApprovals/{requestApprovalId}/query" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if requestApprovalID == "" { + return nil, errors.New("parameter requestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{requestApprovalId}", url.PathEscape(requestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// queryRequestApprovalHandleResponse handles the QueryRequestApproval response. +func (client *PrivateStoreClient) queryRequestApprovalHandleResponse(resp *http.Response) (PrivateStoreQueryRequestApprovalResponse, error) { + result := PrivateStoreQueryRequestApprovalResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.QueryRequestApproval); err != nil { + return PrivateStoreQueryRequestApprovalResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// queryRequestApprovalHandleError handles the QueryRequestApproval error response. +func (client *PrivateStoreClient) queryRequestApprovalHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// UpdateAdminRequestApproval - Update the admin action, weather the request is approved or rejected and the approved plans +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) UpdateAdminRequestApproval(ctx context.Context, privateStoreID string, adminRequestApprovalID string, options *PrivateStoreUpdateAdminRequestApprovalOptions) (PrivateStoreUpdateAdminRequestApprovalResponse, error) { + req, err := client.updateAdminRequestApprovalCreateRequest(ctx, privateStoreID, adminRequestApprovalID, options) + if err != nil { + return PrivateStoreUpdateAdminRequestApprovalResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreUpdateAdminRequestApprovalResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreUpdateAdminRequestApprovalResponse{}, client.updateAdminRequestApprovalHandleError(resp) + } + return client.updateAdminRequestApprovalHandleResponse(resp) +} + +// updateAdminRequestApprovalCreateRequest creates the UpdateAdminRequestApproval request. +func (client *PrivateStoreClient) updateAdminRequestApprovalCreateRequest(ctx context.Context, privateStoreID string, adminRequestApprovalID string, options *PrivateStoreUpdateAdminRequestApprovalOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/adminRequestApprovals/{adminRequestApprovalId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if adminRequestApprovalID == "" { + return nil, errors.New("parameter adminRequestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{adminRequestApprovalId}", url.PathEscape(adminRequestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// updateAdminRequestApprovalHandleResponse handles the UpdateAdminRequestApproval response. +func (client *PrivateStoreClient) updateAdminRequestApprovalHandleResponse(resp *http.Response) (PrivateStoreUpdateAdminRequestApprovalResponse, error) { + result := PrivateStoreUpdateAdminRequestApprovalResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AdminRequestApprovalsResource); err != nil { + return PrivateStoreUpdateAdminRequestApprovalResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateAdminRequestApprovalHandleError handles the UpdateAdminRequestApproval error response. +func (client *PrivateStoreClient) updateAdminRequestApprovalHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// WithdrawPlan - Withdraw a user request approval on specific plan +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreClient) WithdrawPlan(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreWithdrawPlanOptions) (PrivateStoreWithdrawPlanResponse, error) { + req, err := client.withdrawPlanCreateRequest(ctx, privateStoreID, requestApprovalID, options) + if err != nil { + return PrivateStoreWithdrawPlanResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreWithdrawPlanResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreWithdrawPlanResponse{}, client.withdrawPlanHandleError(resp) + } + return PrivateStoreWithdrawPlanResponse{RawResponse: resp}, nil +} + +// withdrawPlanCreateRequest creates the WithdrawPlan request. +func (client *PrivateStoreClient) withdrawPlanCreateRequest(ctx context.Context, privateStoreID string, requestApprovalID string, options *PrivateStoreWithdrawPlanOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/requestApprovals/{requestApprovalId}/withdrawPlan" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if requestApprovalID == "" { + return nil, errors.New("parameter requestApprovalID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{requestApprovalId}", url.PathEscape(requestApprovalID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// withdrawPlanHandleError handles the WithdrawPlan error response. +func (client *PrivateStoreClient) withdrawPlanHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollection_client.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollection_client.go new file mode 100644 index 000000000000..4f32285aa8c5 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollection_client.go @@ -0,0 +1,395 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrivateStoreCollectionClient contains the methods for the PrivateStoreCollection group. +// Don't use this type directly, use NewPrivateStoreCollectionClient() instead. +type PrivateStoreCollectionClient struct { + ep string + pl runtime.Pipeline +} + +// NewPrivateStoreCollectionClient creates a new instance of PrivateStoreCollectionClient with the specified values. +func NewPrivateStoreCollectionClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateStoreCollectionClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateStoreCollectionClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update private store collection +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) CreateOrUpdate(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionCreateOrUpdateOptions) (PrivateStoreCollectionCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, privateStoreID, collectionID, options) + if err != nil { + return PrivateStoreCollectionCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateStoreCollectionClient) createOrUpdateCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PrivateStoreCollectionClient) createOrUpdateHandleResponse(resp *http.Response) (PrivateStoreCollectionCreateOrUpdateResponse, error) { + result := PrivateStoreCollectionCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Collection); err != nil { + return PrivateStoreCollectionCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateStoreCollectionClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a collection from the given private store. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) Delete(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionDeleteOptions) (PrivateStoreCollectionDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, privateStoreID, collectionID, options) + if err != nil { + return PrivateStoreCollectionDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PrivateStoreCollectionDeleteResponse{}, client.deleteHandleError(resp) + } + return PrivateStoreCollectionDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateStoreCollectionClient) deleteCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateStoreCollectionClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets private store collection +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) Get(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionGetOptions) (PrivateStoreCollectionGetResponse, error) { + req, err := client.getCreateRequest(ctx, privateStoreID, collectionID, options) + if err != nil { + return PrivateStoreCollectionGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateStoreCollectionClient) getCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateStoreCollectionClient) getHandleResponse(resp *http.Response) (PrivateStoreCollectionGetResponse, error) { + result := PrivateStoreCollectionGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Collection); err != nil { + return PrivateStoreCollectionGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateStoreCollectionClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Gets private store collections list +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) List(ctx context.Context, privateStoreID string, options *PrivateStoreCollectionListOptions) (PrivateStoreCollectionListResponse, error) { + req, err := client.listCreateRequest(ctx, privateStoreID, options) + if err != nil { + return PrivateStoreCollectionListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateStoreCollectionClient) listCreateRequest(ctx context.Context, privateStoreID string, options *PrivateStoreCollectionListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateStoreCollectionClient) listHandleResponse(resp *http.Response) (PrivateStoreCollectionListResponse, error) { + result := PrivateStoreCollectionListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CollectionsList); err != nil { + return PrivateStoreCollectionListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateStoreCollectionClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Post - Delete Private store collection. This is a workaround. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) Post(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionPostOptions) (PrivateStoreCollectionPostResponse, error) { + req, err := client.postCreateRequest(ctx, privateStoreID, collectionID, options) + if err != nil { + return PrivateStoreCollectionPostResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionPostResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionPostResponse{}, client.postHandleError(resp) + } + return PrivateStoreCollectionPostResponse{RawResponse: resp}, nil +} + +// postCreateRequest creates the Post request. +func (client *PrivateStoreCollectionClient) postCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionPostOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// postHandleError handles the Post error response. +func (client *PrivateStoreCollectionClient) postHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// TransferOffers - transferring offers (copy or move) from source collection to target collection(s) +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionClient) TransferOffers(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionTransferOffersOptions) (PrivateStoreCollectionTransferOffersResponse, error) { + req, err := client.transferOffersCreateRequest(ctx, privateStoreID, collectionID, options) + if err != nil { + return PrivateStoreCollectionTransferOffersResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionTransferOffersResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionTransferOffersResponse{}, client.transferOffersHandleError(resp) + } + return client.transferOffersHandleResponse(resp) +} + +// transferOffersCreateRequest creates the TransferOffers request. +func (client *PrivateStoreCollectionClient) transferOffersCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionTransferOffersOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/transferOffers" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// transferOffersHandleResponse handles the TransferOffers response. +func (client *PrivateStoreCollectionClient) transferOffersHandleResponse(resp *http.Response) (PrivateStoreCollectionTransferOffersResponse, error) { + result := PrivateStoreCollectionTransferOffersResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TransferOffersResponse); err != nil { + return PrivateStoreCollectionTransferOffersResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// transferOffersHandleError handles the TransferOffers error response. +func (client *PrivateStoreCollectionClient) transferOffersHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollectionoffer_client.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollectionoffer_client.go new file mode 100644 index 000000000000..299ab4529685 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_privatestorecollectionoffer_client.go @@ -0,0 +1,348 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrivateStoreCollectionOfferClient contains the methods for the PrivateStoreCollectionOffer group. +// Don't use this type directly, use NewPrivateStoreCollectionOfferClient() instead. +type PrivateStoreCollectionOfferClient struct { + ep string + pl runtime.Pipeline +} + +// NewPrivateStoreCollectionOfferClient creates a new instance of PrivateStoreCollectionOfferClient with the specified values. +func NewPrivateStoreCollectionOfferClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateStoreCollectionOfferClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateStoreCollectionOfferClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Update or add an offer to a specific collection of the private store. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionOfferClient) CreateOrUpdate(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferCreateOrUpdateOptions) (PrivateStoreCollectionOfferCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, privateStoreID, offerID, collectionID, options) + if err != nil { + return PrivateStoreCollectionOfferCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionOfferCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionOfferCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateStoreCollectionOfferClient) createOrUpdateCreateRequest(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/offers/{offerId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PrivateStoreCollectionOfferClient) createOrUpdateHandleResponse(resp *http.Response) (PrivateStoreCollectionOfferCreateOrUpdateResponse, error) { + result := PrivateStoreCollectionOfferCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Offer); err != nil { + return PrivateStoreCollectionOfferCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateStoreCollectionOfferClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes an offer from the given collection of private store. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionOfferClient) Delete(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferDeleteOptions) (PrivateStoreCollectionOfferDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, privateStoreID, offerID, collectionID, options) + if err != nil { + return PrivateStoreCollectionOfferDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionOfferDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PrivateStoreCollectionOfferDeleteResponse{}, client.deleteHandleError(resp) + } + return PrivateStoreCollectionOfferDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateStoreCollectionOfferClient) deleteCreateRequest(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/offers/{offerId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateStoreCollectionOfferClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets information about a specific offer. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionOfferClient) Get(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferGetOptions) (PrivateStoreCollectionOfferGetResponse, error) { + req, err := client.getCreateRequest(ctx, privateStoreID, offerID, collectionID, options) + if err != nil { + return PrivateStoreCollectionOfferGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionOfferGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionOfferGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateStoreCollectionOfferClient) getCreateRequest(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/offers/{offerId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateStoreCollectionOfferClient) getHandleResponse(resp *http.Response) (PrivateStoreCollectionOfferGetResponse, error) { + result := PrivateStoreCollectionOfferGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Offer); err != nil { + return PrivateStoreCollectionOfferGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateStoreCollectionOfferClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of all private offers in the given private store and collection +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionOfferClient) List(privateStoreID string, collectionID string, options *PrivateStoreCollectionOfferListOptions) *PrivateStoreCollectionOfferListPager { + return &PrivateStoreCollectionOfferListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, privateStoreID, collectionID, options) + }, + advancer: func(ctx context.Context, resp PrivateStoreCollectionOfferListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OfferListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateStoreCollectionOfferClient) listCreateRequest(ctx context.Context, privateStoreID string, collectionID string, options *PrivateStoreCollectionOfferListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/offers" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateStoreCollectionOfferClient) listHandleResponse(resp *http.Response) (PrivateStoreCollectionOfferListResponse, error) { + result := PrivateStoreCollectionOfferListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OfferListResponse); err != nil { + return PrivateStoreCollectionOfferListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateStoreCollectionOfferClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Post - Delete Private store offer. This is a workaround. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateStoreCollectionOfferClient) Post(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferPostOptions) (PrivateStoreCollectionOfferPostResponse, error) { + req, err := client.postCreateRequest(ctx, privateStoreID, offerID, collectionID, options) + if err != nil { + return PrivateStoreCollectionOfferPostResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateStoreCollectionOfferPostResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateStoreCollectionOfferPostResponse{}, client.postHandleError(resp) + } + return PrivateStoreCollectionOfferPostResponse{RawResponse: resp}, nil +} + +// postCreateRequest creates the Post request. +func (client *PrivateStoreCollectionOfferClient) postCreateRequest(ctx context.Context, privateStoreID string, offerID string, collectionID string, options *PrivateStoreCollectionOfferPostOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Marketplace/privateStores/{privateStoreId}/collections/{collectionId}/offers/{offerId}" + if privateStoreID == "" { + return nil, errors.New("parameter privateStoreID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateStoreId}", url.PathEscape(privateStoreID)) + if offerID == "" { + return nil, errors.New("parameter offerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{offerId}", url.PathEscape(offerID)) + if collectionID == "" { + return nil, errors.New("parameter collectionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{collectionId}", url.PathEscape(collectionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Payload != nil { + return req, runtime.MarshalAsJSON(req, *options.Payload) + } + return req, nil +} + +// postHandleError handles the Post error response. +func (client *PrivateStoreCollectionOfferClient) postHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_response_types.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_response_types.go new file mode 100644 index 000000000000..d3393c09730f --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_response_types.go @@ -0,0 +1,335 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import "net/http" + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// PrivateStoreAcknowledgeOfferNotificationResponse contains the response from method PrivateStore.AcknowledgeOfferNotification. +type PrivateStoreAcknowledgeOfferNotificationResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreAdminRequestApprovalsListResponse contains the response from method PrivateStore.AdminRequestApprovalsList. +type PrivateStoreAdminRequestApprovalsListResponse struct { + PrivateStoreAdminRequestApprovalsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreAdminRequestApprovalsListResult contains the result from method PrivateStore.AdminRequestApprovalsList. +type PrivateStoreAdminRequestApprovalsListResult struct { + AdminRequestApprovalsList +} + +// PrivateStoreBillingAccountsResponse contains the response from method PrivateStore.BillingAccounts. +type PrivateStoreBillingAccountsResponse struct { + PrivateStoreBillingAccountsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreBillingAccountsResult contains the result from method PrivateStore.BillingAccounts. +type PrivateStoreBillingAccountsResult struct { + BillingAccountsResponse +} + +// PrivateStoreBulkCollectionsActionResponse contains the response from method PrivateStore.BulkCollectionsAction. +type PrivateStoreBulkCollectionsActionResponse struct { + PrivateStoreBulkCollectionsActionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreBulkCollectionsActionResult contains the result from method PrivateStore.BulkCollectionsAction. +type PrivateStoreBulkCollectionsActionResult struct { + BulkCollectionsResponse +} + +// PrivateStoreCollectionCreateOrUpdateResponse contains the response from method PrivateStoreCollection.CreateOrUpdate. +type PrivateStoreCollectionCreateOrUpdateResponse struct { + PrivateStoreCollectionCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionCreateOrUpdateResult contains the result from method PrivateStoreCollection.CreateOrUpdate. +type PrivateStoreCollectionCreateOrUpdateResult struct { + Collection +} + +// PrivateStoreCollectionDeleteResponse contains the response from method PrivateStoreCollection.Delete. +type PrivateStoreCollectionDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionGetResponse contains the response from method PrivateStoreCollection.Get. +type PrivateStoreCollectionGetResponse struct { + PrivateStoreCollectionGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionGetResult contains the result from method PrivateStoreCollection.Get. +type PrivateStoreCollectionGetResult struct { + Collection +} + +// PrivateStoreCollectionListResponse contains the response from method PrivateStoreCollection.List. +type PrivateStoreCollectionListResponse struct { + PrivateStoreCollectionListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionListResult contains the result from method PrivateStoreCollection.List. +type PrivateStoreCollectionListResult struct { + CollectionsList +} + +// PrivateStoreCollectionOfferCreateOrUpdateResponse contains the response from method PrivateStoreCollectionOffer.CreateOrUpdate. +type PrivateStoreCollectionOfferCreateOrUpdateResponse struct { + PrivateStoreCollectionOfferCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionOfferCreateOrUpdateResult contains the result from method PrivateStoreCollectionOffer.CreateOrUpdate. +type PrivateStoreCollectionOfferCreateOrUpdateResult struct { + Offer +} + +// PrivateStoreCollectionOfferDeleteResponse contains the response from method PrivateStoreCollectionOffer.Delete. +type PrivateStoreCollectionOfferDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionOfferGetResponse contains the response from method PrivateStoreCollectionOffer.Get. +type PrivateStoreCollectionOfferGetResponse struct { + PrivateStoreCollectionOfferGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionOfferGetResult contains the result from method PrivateStoreCollectionOffer.Get. +type PrivateStoreCollectionOfferGetResult struct { + Offer +} + +// PrivateStoreCollectionOfferListResponse contains the response from method PrivateStoreCollectionOffer.List. +type PrivateStoreCollectionOfferListResponse struct { + PrivateStoreCollectionOfferListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionOfferListResult contains the result from method PrivateStoreCollectionOffer.List. +type PrivateStoreCollectionOfferListResult struct { + OfferListResponse +} + +// PrivateStoreCollectionOfferPostResponse contains the response from method PrivateStoreCollectionOffer.Post. +type PrivateStoreCollectionOfferPostResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionPostResponse contains the response from method PrivateStoreCollection.Post. +type PrivateStoreCollectionPostResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionTransferOffersResponse contains the response from method PrivateStoreCollection.TransferOffers. +type PrivateStoreCollectionTransferOffersResponse struct { + PrivateStoreCollectionTransferOffersResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionTransferOffersResult contains the result from method PrivateStoreCollection.TransferOffers. +type PrivateStoreCollectionTransferOffersResult struct { + TransferOffersResponse +} + +// PrivateStoreCollectionsToSubscriptionsMappingResponse contains the response from method PrivateStore.CollectionsToSubscriptionsMapping. +type PrivateStoreCollectionsToSubscriptionsMappingResponse struct { + PrivateStoreCollectionsToSubscriptionsMappingResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCollectionsToSubscriptionsMappingResult contains the result from method PrivateStore.CollectionsToSubscriptionsMapping. +type PrivateStoreCollectionsToSubscriptionsMappingResult struct { + CollectionsToSubscriptionsMappingResponse +} + +// PrivateStoreCreateApprovalRequestResponse contains the response from method PrivateStore.CreateApprovalRequest. +type PrivateStoreCreateApprovalRequestResponse struct { + PrivateStoreCreateApprovalRequestResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreCreateApprovalRequestResult contains the result from method PrivateStore.CreateApprovalRequest. +type PrivateStoreCreateApprovalRequestResult struct { + RequestApprovalResource +} + +// PrivateStoreCreateOrUpdateResponse contains the response from method PrivateStore.CreateOrUpdate. +type PrivateStoreCreateOrUpdateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreDeleteResponse contains the response from method PrivateStore.Delete. +type PrivateStoreDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreGetAdminRequestApprovalResponse contains the response from method PrivateStore.GetAdminRequestApproval. +type PrivateStoreGetAdminRequestApprovalResponse struct { + PrivateStoreGetAdminRequestApprovalResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreGetAdminRequestApprovalResult contains the result from method PrivateStore.GetAdminRequestApproval. +type PrivateStoreGetAdminRequestApprovalResult struct { + AdminRequestApprovalsResource +} + +// PrivateStoreGetApprovalRequestsListResponse contains the response from method PrivateStore.GetApprovalRequestsList. +type PrivateStoreGetApprovalRequestsListResponse struct { + PrivateStoreGetApprovalRequestsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreGetApprovalRequestsListResult contains the result from method PrivateStore.GetApprovalRequestsList. +type PrivateStoreGetApprovalRequestsListResult struct { + RequestApprovalsList +} + +// PrivateStoreGetRequestApprovalResponse contains the response from method PrivateStore.GetRequestApproval. +type PrivateStoreGetRequestApprovalResponse struct { + PrivateStoreGetRequestApprovalResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreGetRequestApprovalResult contains the result from method PrivateStore.GetRequestApproval. +type PrivateStoreGetRequestApprovalResult struct { + RequestApprovalResource +} + +// PrivateStoreGetResponse contains the response from method PrivateStore.Get. +type PrivateStoreGetResponse struct { + PrivateStoreGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreGetResult contains the result from method PrivateStore.Get. +type PrivateStoreGetResult struct { + PrivateStore +} + +// PrivateStoreListResponse contains the response from method PrivateStore.List. +type PrivateStoreListResponse struct { + PrivateStoreListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreListResult contains the result from method PrivateStore.List. +type PrivateStoreListResult struct { + PrivateStoreList +} + +// PrivateStoreQueryApprovedPlansResponse contains the response from method PrivateStore.QueryApprovedPlans. +type PrivateStoreQueryApprovedPlansResponse struct { + PrivateStoreQueryApprovedPlansResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreQueryApprovedPlansResult contains the result from method PrivateStore.QueryApprovedPlans. +type PrivateStoreQueryApprovedPlansResult struct { + QueryApprovedPlansResponse +} + +// PrivateStoreQueryNotificationsStateResponse contains the response from method PrivateStore.QueryNotificationsState. +type PrivateStoreQueryNotificationsStateResponse struct { + PrivateStoreQueryNotificationsStateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreQueryNotificationsStateResult contains the result from method PrivateStore.QueryNotificationsState. +type PrivateStoreQueryNotificationsStateResult struct { + PrivateStoreNotificationsState +} + +// PrivateStoreQueryOffersResponse contains the response from method PrivateStore.QueryOffers. +type PrivateStoreQueryOffersResponse struct { + PrivateStoreQueryOffersResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreQueryOffersResult contains the result from method PrivateStore.QueryOffers. +type PrivateStoreQueryOffersResult struct { + QueryOffers +} + +// PrivateStoreQueryRequestApprovalResponse contains the response from method PrivateStore.QueryRequestApproval. +type PrivateStoreQueryRequestApprovalResponse struct { + PrivateStoreQueryRequestApprovalResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreQueryRequestApprovalResult contains the result from method PrivateStore.QueryRequestApproval. +type PrivateStoreQueryRequestApprovalResult struct { + QueryRequestApproval +} + +// PrivateStoreUpdateAdminRequestApprovalResponse contains the response from method PrivateStore.UpdateAdminRequestApproval. +type PrivateStoreUpdateAdminRequestApprovalResponse struct { + PrivateStoreUpdateAdminRequestApprovalResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateStoreUpdateAdminRequestApprovalResult contains the result from method PrivateStore.UpdateAdminRequestApproval. +type PrivateStoreUpdateAdminRequestApprovalResult struct { + AdminRequestApprovalsResource +} + +// PrivateStoreWithdrawPlanResponse contains the response from method PrivateStore.WithdrawPlan. +type PrivateStoreWithdrawPlanResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} diff --git a/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_time_rfc3339.go b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..f606f309d522 --- /dev/null +++ b/sdk/resourcemanager/marketplace/armmarketplace/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmarketplace + +import ( + "encoding/json" + "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]interface{}, 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, 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 err + } + *t = (*time.Time)(&aux) + return nil +}