diff --git a/internal/clients/client.go b/internal/clients/client.go index 62398f25f7c0..a5fd81ee00e7 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -312,7 +312,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.Communication, err = communication.NewClient(o); err != nil { return fmt.Errorf("building clients for Communication: %+v", err) } - client.Compute = compute.NewClient(o) + if client.Compute, err = compute.NewClient(o); err != nil { + return fmt.Errorf("building clients for Compute: %+v", err) + } if client.ConfidentialLedger, err = confidentialledger.NewClient(o); err != nil { return fmt.Errorf("building clients for ConfidentialLedger: %+v", err) } diff --git a/internal/services/compute/client/client.go b/internal/services/compute/client/client.go index 47d5f8572fc4..f1d6dddc5ebe 100644 --- a/internal/services/compute/client/client.go +++ b/internal/services/compute/client/client.go @@ -1,7 +1,8 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering" // nolint: staticcheck + "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2021-07-01/skus" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2021-11-01/availabilitysets" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2021-11-01/dedicatedhostgroups" @@ -19,6 +20,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleries" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryapplications" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryapplicationversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/common" "github.com/tombuildsstuff/kermit/sdk/compute/2023-03-01/compute" ) @@ -38,7 +40,7 @@ type Client struct { GalleryImagesClient *compute.GalleryImagesClient GalleryImageVersionsClient *compute.GalleryImageVersionsClient ImagesClient *images.ImagesClient - MarketplaceAgreementsClient *marketplaceordering.MarketplaceAgreementsClient + MarketplaceAgreementsClient *agreements.AgreementsClient ProximityPlacementGroupsClient *proximityplacementgroups.ProximityPlacementGroupsClient SkusClient *skus.SkusClient SSHPublicKeysClient *sshpublickeys.SshPublicKeysClient @@ -54,7 +56,7 @@ type Client struct { VMImageClient *compute.VirtualMachineImagesClient } -func NewClient(o *common.ClientOptions) *Client { +func NewClient(o *common.ClientOptions) (*Client, error) { availabilitySetsClient := availabilitysets.NewAvailabilitySetsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&availabilitySetsClient.Client, o.ResourceManagerAuthorizer) @@ -97,8 +99,11 @@ func NewClient(o *common.ClientOptions) *Client { imagesClient := images.NewImagesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&imagesClient.Client, o.ResourceManagerAuthorizer) - marketplaceAgreementsClient := marketplaceordering.NewMarketplaceAgreementsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&marketplaceAgreementsClient.Client, o.ResourceManagerAuthorizer) + marketplaceAgreementsClient, err := agreements.NewAgreementsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building MarketplaceAgreementsClient client: %+v", err) + } + o.Configure(marketplaceAgreementsClient.Client, o.Authorizers.ResourceManager) proximityPlacementGroupsClient := proximityplacementgroups.NewProximityPlacementGroupsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&proximityPlacementGroupsClient.Client, o.ResourceManagerAuthorizer) @@ -157,7 +162,7 @@ func NewClient(o *common.ClientOptions) *Client { GalleryImagesClient: &galleryImagesClient, GalleryImageVersionsClient: &galleryImageVersionsClient, ImagesClient: &imagesClient, - MarketplaceAgreementsClient: &marketplaceAgreementsClient, + MarketplaceAgreementsClient: marketplaceAgreementsClient, ProximityPlacementGroupsClient: &proximityPlacementGroupsClient, SkusClient: &skusClient, SSHPublicKeysClient: &sshPublicKeysClient, @@ -173,5 +178,5 @@ func NewClient(o *common.ClientOptions) *Client { // NOTE: use `VirtualMachinesClient` instead VMClient: &vmClient, - } + }, nil } diff --git a/internal/services/compute/linux_virtual_machine_resource_images_test.go b/internal/services/compute/linux_virtual_machine_resource_images_test.go index 5ba42972786b..d69f8e6a4e11 100644 --- a/internal/services/compute/linux_virtual_machine_resource_images_test.go +++ b/internal/services/compute/linux_virtual_machine_resource_images_test.go @@ -4,13 +4,14 @@ import ( "context" "fmt" "testing" + "time" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func TestAccLinuxVirtualMachine_imageFromImage(t *testing.T) { @@ -412,21 +413,28 @@ provider "azurerm" { func (r LinuxVirtualMachineResource) cancelExistingAgreement(publisher string, offer string, sku string) acceptance.ClientCheckFunc { return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { client := clients.Compute.MarketplaceAgreementsClient - id := parse.NewPlanID(client.SubscriptionID, publisher, offer, sku) + subscriptionId := clients.Account.SubscriptionId + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute)) + defer cancel() - existing, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + idGet := agreements.NewOfferPlanID(subscriptionId, publisher, offer, sku) + idCancel := agreements.NewPlanID(subscriptionId, publisher, offer, sku) + + existing, err := client.MarketplaceAgreementsGet(ctx, idGet) if err != nil { return err } - if props := existing.AgreementProperties; props != nil { - if accepted := props.Accepted; accepted != nil && *accepted { - resp, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("marketplace agreement %q does not exist", id) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted; accepted != nil && *accepted { + resp, err := client.MarketplaceAgreementsCancel(ctx, idCancel) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("marketplace agreement %q does not exist", idGet) + } + return fmt.Errorf("canceling %s: %+v", idGet, err) } - return fmt.Errorf("canceling Marketplace Agreement : %+v", err) } } } diff --git a/internal/services/compute/linux_virtual_machine_scale_set_images_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_images_resource_test.go index defbf7acb995..d08ef7ef2f95 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_images_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_images_resource_test.go @@ -4,13 +4,14 @@ import ( "context" "fmt" "testing" + "time" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func TestAccLinuxVirtualMachineScaleSet_imagesAutomaticUpdate(t *testing.T) { @@ -763,21 +764,28 @@ provider "azurerm" { func (r LinuxVirtualMachineScaleSetResource) cancelExistingAgreement(publisher string, offer string, sku string) acceptance.ClientCheckFunc { return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { client := clients.Compute.MarketplaceAgreementsClient - id := parse.NewPlanID(client.SubscriptionID, publisher, offer, sku) + subscriptionId := clients.Account.SubscriptionId + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute)) + defer cancel() - existing, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + idGet := agreements.NewOfferPlanID(subscriptionId, publisher, offer, sku) + idCancel := agreements.NewPlanID(subscriptionId, publisher, offer, sku) + + existing, err := client.MarketplaceAgreementsGet(ctx, idGet) if err != nil { return err } - if props := existing.AgreementProperties; props != nil { - if accepted := props.Accepted; accepted != nil && *accepted { - resp, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("marketplace agreement %q does not exist", id) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted; accepted != nil && *accepted { + resp, err := client.MarketplaceAgreementsCancel(ctx, idCancel) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("marketplace agreement %q does not exist", idGet) + } + return fmt.Errorf("canceling %s: %+v", idGet, err) } - return fmt.Errorf("canceling Marketplace Agreement : %+v", err) } } } diff --git a/internal/services/compute/marketplace_agreement_data_source.go b/internal/services/compute/marketplace_agreement_data_source.go index 8b40680c7df0..e686248afc8d 100644 --- a/internal/services/compute/marketplace_agreement_data_source.go +++ b/internal/services/compute/marketplace_agreement_data_source.go @@ -5,12 +5,12 @@ import ( "log" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceMarketplaceAgreement() *pluginsdk.Resource { @@ -59,13 +59,13 @@ func dataSourceMarketplaceAgreementRead(d *pluginsdk.ResourceData, meta interfac ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewPlanID(subscriptionId, d.Get("publisher").(string), d.Get("offer").(string), d.Get("plan").(string)) + id := agreements.NewOfferPlanID(subscriptionId, d.Get("publisher").(string), d.Get("offer").(string), d.Get("plan").(string)) log.Printf("[DEBUG] retrieving %s", id) - term, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + term, err := client.MarketplaceAgreementsGet(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(term.Response) { + if !response.WasNotFound(term.HttpResponse) { return fmt.Errorf("%s was not found", id) } @@ -73,11 +73,11 @@ func dataSourceMarketplaceAgreementRead(d *pluginsdk.ResourceData, meta interfac } d.SetId(id.ID()) - - if props := term.AgreementProperties; props != nil { - d.Set("license_text_link", props.LicenseTextLink) - d.Set("privacy_policy_link", props.PrivacyPolicyLink) + if model := term.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("license_text_link", props.LicenseTextLink) + d.Set("privacy_policy_link", props.PrivacyPolicyLink) + } } - return nil } diff --git a/internal/services/compute/marketplace_agreement_resource.go b/internal/services/compute/marketplace_agreement_resource.go index 43eee94f56dc..51f62564b2fb 100644 --- a/internal/services/compute/marketplace_agreement_resource.go +++ b/internal/services/compute/marketplace_agreement_resource.go @@ -5,9 +5,10 @@ import ( "log" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -20,7 +21,7 @@ func resourceMarketplaceAgreement() *pluginsdk.Resource { Read: resourceMarketplaceAgreementRead, Delete: resourceMarketplaceAgreementDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.PlanID(id) + _, err := agreements.ParseOfferPlanID(id) return err }), @@ -72,46 +73,53 @@ func resourceMarketplaceAgreementCreateUpdate(d *pluginsdk.ResourceData, meta in subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() - id := parse.NewPlanID(subscriptionId, d.Get("publisher").(string), d.Get("offer").(string), d.Get("plan").(string)) + id := agreements.NewOfferPlanID(subscriptionId, d.Get("publisher").(string), d.Get("offer").(string), d.Get("plan").(string)) log.Printf("[DEBUG] retrieving %s", id) - term, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + term, err := client.MarketplaceAgreementsGet(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(term.Response) { + if !response.WasNotFound(term.HttpResponse) { return fmt.Errorf("retrieving %s: %s", id, err) } } accepted := false - if props := term.AgreementProperties; props != nil { - if acc := props.Accepted; acc != nil { - accepted = *acc + if model := term.Model; model != nil { + if props := model.Properties; props != nil { + if acc := props.Accepted; acc != nil { + accepted = *acc + } } } - if accepted { - agreement, err := client.GetAgreement(ctx, id.AgreementName, id.OfferName, id.Name) + agreement, err := client.MarketplaceAgreementsGet(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(agreement.Response) { + if !response.WasNotFound(agreement.HttpResponse) { return fmt.Errorf("retrieving %s: %s", id, err) } } return tf.ImportAsExistsError("azurerm_marketplace_agreement", id.ID()) } - terms, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + resp, err := client.MarketplaceAgreementsGet(ctx, id) if err != nil { return fmt.Errorf("retrieving %s: %s", id, err) } - if terms.AgreementProperties == nil { + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: Model was nil", id) + } + + terms := resp.Model + if terms.Properties == nil { return fmt.Errorf("retrieving %s: AgreementProperties was nil", id) } - terms.AgreementProperties.Accepted = utils.Bool(true) + terms.Properties.Accepted = utils.Bool(true) log.Printf("[DEBUG] Accepting the Marketplace Terms for %s", id) - if _, err := client.Create(ctx, id.AgreementName, id.OfferName, id.Name, terms); err != nil { + if _, err := client.MarketplaceAgreementsCreate(ctx, id, *terms); err != nil { return fmt.Errorf("accepting Terms for %s: %s", id, err) } log.Printf("[DEBUG] Accepted the Marketplace Terms for %s", id) @@ -126,35 +134,36 @@ func resourceMarketplaceAgreementRead(d *pluginsdk.ResourceData, meta interface{ ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.PlanID(d.Id()) + id, err := agreements.ParseOfferPlanID(d.Id()) if err != nil { return err } - term, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + term, err := client.MarketplaceAgreementsGet(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(term.Response) { - log.Printf("[DEBUG] The Marketplace Terms was not found for Publisher %q / Offer %q / Plan %q", id.AgreementName, id.OfferName, id.Name) + if response.WasNotFound(term.HttpResponse) { + log.Printf("[DEBUG] The Marketplace Terms was not found for %s", id) d.SetId("") return nil } - return fmt.Errorf("retrieving the Marketplace Terms for Publisher %q / Offer %q / Plan %q: %s", id.AgreementName, id.OfferName, id.Name, err) + return fmt.Errorf("retrieving the Marketplace Terms for %s: %s", id, err) } - d.Set("publisher", id.AgreementName) - d.Set("offer", id.OfferName) - d.Set("plan", id.Name) + d.Set("publisher", id.PublisherId) + d.Set("offer", id.OfferId) + d.Set("plan", id.PlanId) - if props := term.AgreementProperties; props != nil { - if accepted := props.Accepted != nil && *props.Accepted; !accepted { - // if props.Accepted is not true, the agreement does not exist - d.SetId("") + if model := term.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted != nil && *props.Accepted; !accepted { + // if props.Accepted is not true, the agreement does not exist + d.SetId("") + } + d.Set("license_text_link", props.LicenseTextLink) + d.Set("privacy_policy_link", props.PrivacyPolicyLink) } - d.Set("license_text_link", props.LicenseTextLink) - d.Set("privacy_policy_link", props.PrivacyPolicyLink) } - return nil } @@ -163,13 +172,14 @@ func resourceMarketplaceAgreementDelete(d *pluginsdk.ResourceData, meta interfac ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.PlanID(d.Id()) + id, err := agreements.ParseOfferPlanID(d.Id()) if err != nil { return err } + idCancel := agreements.NewPlanID(id.SubscriptionId, id.PublisherId, id.OfferId, id.PlanId) - if _, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name); err != nil { - return fmt.Errorf("cancelling agreement for Publisher %q / Offer %q / Plan %q: %s", id.AgreementName, id.OfferName, id.Name, err) + if _, err = client.MarketplaceAgreementsCancel(ctx, idCancel); err != nil { + return fmt.Errorf("cancelling agreement for %s: %s", *id, err) } return nil diff --git a/internal/services/compute/marketplace_agreement_resource_test.go b/internal/services/compute/marketplace_agreement_resource_test.go index ab81d58a2212..3b6a9deb5cf3 100644 --- a/internal/services/compute/marketplace_agreement_resource_test.go +++ b/internal/services/compute/marketplace_agreement_resource_test.go @@ -4,11 +4,14 @@ import ( "context" "fmt" "testing" + "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -65,23 +68,25 @@ func TestAccMarketplaceAgreement_requiresImport(t *testing.T) { } func (t MarketplaceAgreementResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.PlanID(state.ID) + id, err := agreements.ParseOfferPlanID(state.ID) if err != nil { return nil, err } - resp, err := clients.Compute.MarketplaceAgreementsClient.Get(ctx, id.AgreementName, id.OfferName, id.Name) + resp, err := clients.Compute.MarketplaceAgreementsClient.MarketplaceAgreementsGet(ctx, *id) if err != nil { return nil, fmt.Errorf("retrieving Compute Marketplace Agreement %q", id) } - if resp.ID == nil { - return utils.Bool(false), nil + if resp.Model == nil { + return pointer.To(false), fmt.Errorf("retrieving %s, %+v", *id, err) } - if props := resp.AgreementProperties; props != nil { - if accept := props.Accepted; accept != nil && *accept { - return utils.Bool(true), nil + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + if accept := props.Accepted; accept != nil && *accept { + return utils.Bool(true), nil + } } } @@ -125,21 +130,28 @@ provider "azurerm" { func (r MarketplaceAgreementResource) cancelExistingAgreement(offer string) acceptance.ClientCheckFunc { return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { client := clients.Compute.MarketplaceAgreementsClient - id := parse.NewPlanID(client.SubscriptionID, "barracudanetworks", offer, "hourly") + subscriptionId := clients.Account.SubscriptionId + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute)) + defer cancel() + + idGet := agreements.NewOfferPlanID(subscriptionId, "barracudanetworks", offer, "hourly") + idCancel := agreements.NewPlanID(subscriptionId, "barracudanetworks", offer, "hourly") - existing, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + existing, err := client.MarketplaceAgreementsGet(ctx, idGet) if err != nil { return err } - if props := existing.AgreementProperties; props != nil { - if accepted := props.Accepted; accepted != nil && *accepted { - resp, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("marketplace agreement %q does not exist", id) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted; accepted != nil && *accepted { + resp, err := client.MarketplaceAgreementsCancel(ctx, idCancel) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("marketplace agreement %q does not exist", idGet) + } + return fmt.Errorf("canceling %s: %+v", idGet, err) } - return fmt.Errorf("canceling Marketplace Agreement : %+v", err) } } } diff --git a/internal/services/compute/parse/plan.go b/internal/services/compute/parse/plan.go deleted file mode 100644 index 954f2c4876b9..000000000000 --- a/internal/services/compute/parse/plan.go +++ /dev/null @@ -1,73 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PlanId struct { - SubscriptionId string - AgreementName string - OfferName string - Name string -} - -func NewPlanID(subscriptionId, agreementName, offerName, name string) PlanId { - return PlanId{ - SubscriptionId: subscriptionId, - AgreementName: agreementName, - OfferName: offerName, - Name: name, - } -} - -func (id PlanId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Offer Name %q", id.OfferName), - fmt.Sprintf("Agreement Name %q", id.AgreementName), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Plan", segmentsStr) -} - -func (id PlanId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.MarketplaceOrdering/agreements/%s/offers/%s/plans/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.AgreementName, id.OfferName, id.Name) -} - -// PlanID parses a Plan ID into an PlanId struct -func PlanID(input string) (*PlanId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an Plan ID: %+v", input, err) - } - - resourceId := PlanId{ - SubscriptionId: id.SubscriptionID, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.AgreementName, err = id.PopSegment("agreements"); err != nil { - return nil, err - } - if resourceId.OfferName, err = id.PopSegment("offers"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("plans"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/compute/parse/plan_test.go b/internal/services/compute/parse/plan_test.go deleted file mode 100644 index f50e318486f0..000000000000 --- a/internal/services/compute/parse/plan_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PlanId{} - -func TestPlanIDFormatter(t *testing.T) { - actual := NewPlanID("12345678-1234-9876-4563-123456789012", "agreement1", "offer1", "hourly").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/plans/hourly" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPlanID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PlanId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing AgreementName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/", - Error: true, - }, - - { - // missing value for AgreementName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/", - Error: true, - }, - - { - // missing OfferName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/", - Error: true, - }, - - { - // missing value for OfferName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/plans/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/plans/hourly", - Expected: &PlanId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - AgreementName: "agreement1", - OfferName: "offer1", - Name: "hourly", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.MARKETPLACEORDERING/AGREEMENTS/AGREEMENT1/OFFERS/OFFER1/PLANS/HOURLY", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PlanID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.AgreementName != v.Expected.AgreementName { - t.Fatalf("Expected %q but got %q for AgreementName", v.Expected.AgreementName, actual.AgreementName) - } - if actual.OfferName != v.Expected.OfferName { - t.Fatalf("Expected %q but got %q for OfferName", v.Expected.OfferName, actual.OfferName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/compute/validate/plan_id.go b/internal/services/compute/validate/plan_id.go deleted file mode 100644 index 722a9ed7a6f1..000000000000 --- a/internal/services/compute/validate/plan_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" -) - -func PlanID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PlanID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/compute/validate/plan_id_test.go b/internal/services/compute/validate/plan_id_test.go deleted file mode 100644 index 88ef7636fdf0..000000000000 --- a/internal/services/compute/validate/plan_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPlanID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing AgreementName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/", - Valid: false, - }, - - { - // missing value for AgreementName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/", - Valid: false, - }, - - { - // missing OfferName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/", - Valid: false, - }, - - { - // missing value for OfferName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/plans/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MarketplaceOrdering/agreements/agreement1/offers/offer1/plans/hourly", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.MARKETPLACEORDERING/AGREEMENTS/AGREEMENT1/OFFERS/OFFER1/PLANS/HOURLY", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PlanID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/compute/windows_virtual_machine_resource_images_test.go b/internal/services/compute/windows_virtual_machine_resource_images_test.go index 0188b8821cd1..656d7edc803d 100644 --- a/internal/services/compute/windows_virtual_machine_resource_images_test.go +++ b/internal/services/compute/windows_virtual_machine_resource_images_test.go @@ -4,14 +4,15 @@ import ( "context" "fmt" "testing" + "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2021-11-01/virtualmachines" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func TestAccWindowsVirtualMachine_imageFromImage(t *testing.T) { @@ -402,21 +403,28 @@ func (WindowsVirtualMachineResource) generalizeVirtualMachine(ctx context.Contex func (r WindowsVirtualMachineResource) cancelExistingAgreement(publisher string, offer string, sku string) acceptance.ClientCheckFunc { return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { client := clients.Compute.MarketplaceAgreementsClient - id := parse.NewPlanID(client.SubscriptionID, publisher, offer, sku) + subscriptionId := clients.Account.SubscriptionId + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute)) + defer cancel() - existing, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + idGet := agreements.NewOfferPlanID(subscriptionId, publisher, offer, sku) + idCancel := agreements.NewPlanID(subscriptionId, publisher, offer, sku) + + existing, err := client.MarketplaceAgreementsGet(ctx, idGet) if err != nil { return err } - if props := existing.AgreementProperties; props != nil { - if accepted := props.Accepted; accepted != nil && *accepted { - resp, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("marketplace agreement %q does not exist", id) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted; accepted != nil && *accepted { + resp, err := client.MarketplaceAgreementsCancel(ctx, idCancel) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("marketplace agreement %q does not exist", idGet) + } + return fmt.Errorf("canceling %s: %+v", idGet, err) } - return fmt.Errorf("canceling Marketplace Agreement : %+v", err) } } } diff --git a/internal/services/compute/windows_virtual_machine_scale_set_images_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_images_resource_test.go index 1050628d9eba..37850cc90c19 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_images_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_images_resource_test.go @@ -4,13 +4,14 @@ import ( "context" "fmt" "testing" + "time" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func TestAccWindowsVirtualMachineScaleSet_imagesAutomaticUpdate(t *testing.T) { @@ -767,21 +768,28 @@ provider "azurerm" { func (r WindowsVirtualMachineScaleSetResource) cancelExistingAgreement(publisher string, offer string, sku string) acceptance.ClientCheckFunc { return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { client := clients.Compute.MarketplaceAgreementsClient - id := parse.NewPlanID(client.SubscriptionID, publisher, offer, sku) + subscriptionId := clients.Account.SubscriptionId + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute)) + defer cancel() - existing, err := client.Get(ctx, id.AgreementName, id.OfferName, id.Name) + idGet := agreements.NewOfferPlanID(subscriptionId, publisher, offer, sku) + idCancel := agreements.NewPlanID(subscriptionId, publisher, offer, sku) + + existing, err := client.MarketplaceAgreementsGet(ctx, idGet) if err != nil { return err } - if props := existing.AgreementProperties; props != nil { - if accepted := props.Accepted; accepted != nil && *accepted { - resp, err := client.Cancel(ctx, id.AgreementName, id.OfferName, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("marketplace agreement %q does not exist", id) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + if accepted := props.Accepted; accepted != nil && *accepted { + resp, err := client.MarketplaceAgreementsCancel(ctx, idCancel) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("marketplace agreement %q does not exist", idGet) + } + return fmt.Errorf("canceling %s: %+v", idGet, err) } - return fmt.Errorf("canceling Marketplace Agreement : %+v", err) } } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/_meta.json deleted file mode 100644 index e78044ede35a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/marketplaceordering/resource-manager/readme.md", - "tag": "package-2015-06-01", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2015-06-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/marketplaceordering/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/client.go deleted file mode 100644 index f615a662f27d..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/client.go +++ /dev/null @@ -1,43 +0,0 @@ -// Deprecated: Please note, this package has been deprecated. A replacement package is available [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplaceordering/armmarketplaceordering](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplaceordering/armmarketplaceordering). We strongly encourage you to upgrade to continue receiving updates. See [Migration Guide](https://aka.ms/azsdk/golang/t2/migration) for guidance on upgrading. Refer to our [deprecation policy](https://azure.github.io/azure-sdk/policies_support.html) for more details. -// -// Package marketplaceordering implements the Azure ARM Marketplaceordering service API version 2015-06-01. -// -// REST API for MarketplaceOrdering Agreements. -package marketplaceordering - -// 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. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Marketplaceordering - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Marketplaceordering. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/marketplaceagreements.go b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/marketplaceagreements.go deleted file mode 100644 index fea3d1f35a42..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/marketplaceagreements.go +++ /dev/null @@ -1,498 +0,0 @@ -package marketplaceordering - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// MarketplaceAgreementsClient is the REST API for MarketplaceOrdering Agreements. -type MarketplaceAgreementsClient struct { - BaseClient -} - -// NewMarketplaceAgreementsClient creates an instance of the MarketplaceAgreementsClient client. -func NewMarketplaceAgreementsClient(subscriptionID string) MarketplaceAgreementsClient { - return NewMarketplaceAgreementsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewMarketplaceAgreementsClientWithBaseURI creates an instance of the MarketplaceAgreementsClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewMarketplaceAgreementsClientWithBaseURI(baseURI string, subscriptionID string) MarketplaceAgreementsClient { - return MarketplaceAgreementsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Cancel cancel marketplace terms. -// Parameters: -// publisherID - publisher identifier string of image being deployed. -// offerID - offer identifier string of image being deployed. -// planID - plan identifier string of image being deployed. -func (client MarketplaceAgreementsClient) Cancel(ctx context.Context, publisherID string, offerID string, planID string) (result AgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.Cancel") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CancelPreparer(ctx, publisherID, offerID, planID) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Cancel", nil, "Failure preparing request") - return - } - - resp, err := client.CancelSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Cancel", resp, "Failure sending request") - return - } - - result, err = client.CancelResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Cancel", resp, "Failure responding to request") - return - } - - return -} - -// CancelPreparer prepares the Cancel request. -func (client MarketplaceAgreementsClient) CancelPreparer(ctx context.Context, publisherID string, offerID string, planID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "offerId": autorest.Encode("path", offerID), - "planId": autorest.Encode("path", planID), - "publisherId": autorest.Encode("path", publisherID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}/cancel", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CancelSender sends the Cancel request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) CancelSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CancelResponder handles the response to the Cancel request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) CancelResponder(resp *http.Response) (result AgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Create save marketplace terms. -// Parameters: -// publisherID - publisher identifier string of image being deployed. -// offerID - offer identifier string of image being deployed. -// planID - plan identifier string of image being deployed. -// parameters - parameters supplied to the Create Marketplace Terms operation. -func (client MarketplaceAgreementsClient) Create(ctx context.Context, publisherID string, offerID string, planID string, parameters AgreementTerms) (result AgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.Create") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreatePreparer(ctx, publisherID, offerID, planID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client MarketplaceAgreementsClient) CreatePreparer(ctx context.Context, publisherID string, offerID string, planID string, parameters AgreementTerms) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "offerId": autorest.Encode("path", offerID), - "offerType": autorest.Encode("path", "virtualmachine"), - "planId": autorest.Encode("path", planID), - "publisherId": autorest.Encode("path", publisherID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/offerTypes/{offerType}/publishers/{publisherId}/offers/{offerId}/plans/{planId}/agreements/current", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) CreateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) CreateResponder(resp *http.Response) (result AgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get marketplace terms. -// Parameters: -// publisherID - publisher identifier string of image being deployed. -// offerID - offer identifier string of image being deployed. -// planID - plan identifier string of image being deployed. -func (client MarketplaceAgreementsClient) Get(ctx context.Context, publisherID string, offerID string, planID string) (result AgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, publisherID, offerID, planID) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client MarketplaceAgreementsClient) GetPreparer(ctx context.Context, publisherID string, offerID string, planID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "offerId": autorest.Encode("path", offerID), - "offerType": autorest.Encode("path", "virtualmachine"), - "planId": autorest.Encode("path", planID), - "publisherId": autorest.Encode("path", publisherID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/offerTypes/{offerType}/publishers/{publisherId}/offers/{offerId}/plans/{planId}/agreements/current", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) GetResponder(resp *http.Response) (result AgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAgreement get marketplace agreement. -// Parameters: -// publisherID - publisher identifier string of image being deployed. -// offerID - offer identifier string of image being deployed. -// planID - plan identifier string of image being deployed. -func (client MarketplaceAgreementsClient) GetAgreement(ctx context.Context, publisherID string, offerID string, planID string) (result AgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.GetAgreement") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetAgreementPreparer(ctx, publisherID, offerID, planID) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "GetAgreement", nil, "Failure preparing request") - return - } - - resp, err := client.GetAgreementSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "GetAgreement", resp, "Failure sending request") - return - } - - result, err = client.GetAgreementResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "GetAgreement", resp, "Failure responding to request") - return - } - - return -} - -// GetAgreementPreparer prepares the GetAgreement request. -func (client MarketplaceAgreementsClient) GetAgreementPreparer(ctx context.Context, publisherID string, offerID string, planID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "offerId": autorest.Encode("path", offerID), - "planId": autorest.Encode("path", planID), - "publisherId": autorest.Encode("path", publisherID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAgreementSender sends the GetAgreement request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) GetAgreementSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAgreementResponder handles the response to the GetAgreement request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) GetAgreementResponder(resp *http.Response) (result AgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list marketplace agreements in the subscription. -func (client MarketplaceAgreementsClient) List(ctx context.Context) (result ListAgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client MarketplaceAgreementsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/agreements", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) ListResponder(resp *http.Response) (result ListAgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Sign sign marketplace terms. -// Parameters: -// publisherID - publisher identifier string of image being deployed. -// offerID - offer identifier string of image being deployed. -// planID - plan identifier string of image being deployed. -func (client MarketplaceAgreementsClient) Sign(ctx context.Context, publisherID string, offerID string, planID string) (result AgreementTerms, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.Sign") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.SignPreparer(ctx, publisherID, offerID, planID) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Sign", nil, "Failure preparing request") - return - } - - resp, err := client.SignSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Sign", resp, "Failure sending request") - return - } - - result, err = client.SignResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.MarketplaceAgreementsClient", "Sign", resp, "Failure responding to request") - return - } - - return -} - -// SignPreparer prepares the Sign request. -func (client MarketplaceAgreementsClient) SignPreparer(ctx context.Context, publisherID string, offerID string, planID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "offerId": autorest.Encode("path", offerID), - "planId": autorest.Encode("path", planID), - "publisherId": autorest.Encode("path", publisherID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MarketplaceOrdering/agreements/{publisherId}/offers/{offerId}/plans/{planId}/sign", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SignSender sends the Sign request. The method will close the -// http.Response Body if it receives an error. -func (client MarketplaceAgreementsClient) SignSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// SignResponder handles the response to the Sign request. The method always -// closes the http.Response Body. -func (client MarketplaceAgreementsClient) SignResponder(resp *http.Response) (result AgreementTerms, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/models.go deleted file mode 100644 index e3ed58828c12..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/models.go +++ /dev/null @@ -1,343 +0,0 @@ -package marketplaceordering - -// 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. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering" - -// AgreementProperties agreement Terms definition -type AgreementProperties struct { - // Publisher - Publisher identifier string of image being deployed. - Publisher *string `json:"publisher,omitempty"` - // Product - Offer identifier string of image being deployed. - Product *string `json:"product,omitempty"` - // Plan - Plan identifier string of image being deployed. - Plan *string `json:"plan,omitempty"` - // LicenseTextLink - Link to HTML with Microsoft and Publisher terms. - LicenseTextLink *string `json:"licenseTextLink,omitempty"` - // PrivacyPolicyLink - Link to the privacy policy of the publisher. - PrivacyPolicyLink *string `json:"privacyPolicyLink,omitempty"` - // RetrieveDatetime - Date and time in UTC of when the terms were accepted. This is empty if Accepted is false. - RetrieveDatetime *date.Time `json:"retrieveDatetime,omitempty"` - // Signature - Terms signature. - Signature *string `json:"signature,omitempty"` - // Accepted - If any version of the terms have been accepted, otherwise false. - Accepted *bool `json:"accepted,omitempty"` -} - -// AgreementTerms terms properties for provided Publisher/Offer/Plan tuple -type AgreementTerms struct { - autorest.Response `json:"-"` - // AgreementProperties - Represents the properties of the resource. - *AgreementProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for AgreementTerms. -func (at AgreementTerms) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if at.AgreementProperties != nil { - objectMap["properties"] = at.AgreementProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for AgreementTerms struct. -func (at *AgreementTerms) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var agreementProperties AgreementProperties - err = json.Unmarshal(*v, &agreementProperties) - if err != nil { - return err - } - at.AgreementProperties = &agreementProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - at.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - at.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - at.Type = &typeVar - } - } - } - - return nil -} - -// ErrorResponse error response indicates Microsoft.MarketplaceOrdering service is not able to process the -// incoming request. The reason is provided in the error message. -type ErrorResponse struct { - // Error - The details of the error. - Error *ErrorResponseError `json:"error,omitempty"` -} - -// ErrorResponseError the details of the error. -type ErrorResponseError struct { - // Code - READ-ONLY; Error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; Error message indicating why the operation failed. - Message *string `json:"message,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorResponseError. -func (er ErrorResponseError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ListAgreementTerms ... -type ListAgreementTerms struct { - autorest.Response `json:"-"` - Value *[]AgreementTerms `json:"value,omitempty"` -} - -// Operation microsoft.MarketplaceOrdering REST API operation -type Operation struct { - // Name - Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - Service provider: Microsoft.MarketplaceOrdering - Provider *string `json:"provider,omitempty"` - // Resource - Resource on which the operation is performed: Agreement, virtualmachine, etc. - Resource *string `json:"resource,omitempty"` - // Operation - Operation type: Get Agreement, Sign Agreement, Cancel Agreement etc. - Operation *string `json:"operation,omitempty"` -} - -// OperationListResult result of the request to list MarketplaceOrdering operations. It contains a list of -// operations and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - List of Microsoft.MarketplaceOrdering operations supported by the Microsoft.MarketplaceOrdering resource provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationListResult. -func (olr OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if olr.Value != nil { - objectMap["value"] = olr.Value - } - return json.Marshal(objectMap) -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (olr OperationListResult) hasNextLink() bool { - return olr.NextLink != nil && len(*olr.NextLink) != 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !olr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} - -// Resource ARM resource. -type Resource struct { - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/operations.go deleted file mode 100644 index b43750de5e87..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/operations.go +++ /dev/null @@ -1,140 +0,0 @@ -package marketplaceordering - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// OperationsClient is the REST API for MarketplaceOrdering Agreements. -type OperationsClient struct { - BaseClient -} - -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists all of the available Microsoft.MarketplaceOrdering REST API operations. -func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "List", resp, "Failure sending request") - return - } - - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "List", resp, "Failure responding to request") - return - } - if result.olr.hasNextLink() && result.olr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.MarketplaceOrdering/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "marketplaceordering.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/version.go deleted file mode 100644 index e32cecf6710a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package marketplaceordering - -import "github.com/Azure/azure-sdk-for-go/version" - -// 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. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " marketplaceordering/2015-06-01" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/README.md new file mode 100644 index 000000000000..5463ecf689e8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements` Documentation + +The `agreements` SDK allows for interaction with the Azure Resource Manager Service `marketplaceordering` (API Version `2021-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements" +``` + + +### Client Initialization + +```go +client := agreements.NewAgreementsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsCancel` + +```go +ctx := context.TODO() +id := agreements.NewPlanID("12345678-1234-9876-4563-123456789012", "publisherIdValue", "offerIdValue", "planIdValue") + +read, err := client.MarketplaceAgreementsCancel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsCreate` + +```go +ctx := context.TODO() +id := agreements.NewOfferPlanID("12345678-1234-9876-4563-123456789012", "publisherIdValue", "offerIdValue", "planIdValue") + +payload := agreements.AgreementTerms{ + // ... +} + + +read, err := client.MarketplaceAgreementsCreate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsGet` + +```go +ctx := context.TODO() +id := agreements.NewOfferPlanID("12345678-1234-9876-4563-123456789012", "publisherIdValue", "offerIdValue", "planIdValue") + +read, err := client.MarketplaceAgreementsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsGetAgreement` + +```go +ctx := context.TODO() +id := agreements.NewPlanID("12345678-1234-9876-4563-123456789012", "publisherIdValue", "offerIdValue", "planIdValue") + +read, err := client.MarketplaceAgreementsGetAgreement(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsList` + +```go +ctx := context.TODO() +id := agreements.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.MarketplaceAgreementsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgreementsClient.MarketplaceAgreementsSign` + +```go +ctx := context.TODO() +id := agreements.NewPlanID("12345678-1234-9876-4563-123456789012", "publisherIdValue", "offerIdValue", "planIdValue") + +read, err := client.MarketplaceAgreementsSign(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/client.go new file mode 100644 index 000000000000..51de79b933c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/client.go @@ -0,0 +1,26 @@ +package agreements + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgreementsClient struct { + Client *resourcemanager.Client +} + +func NewAgreementsClientWithBaseURI(api environments.Api) (*AgreementsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "agreements", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AgreementsClient: %+v", err) + } + + return &AgreementsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/constants.go new file mode 100644 index 000000000000..3bc517c948c1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/constants.go @@ -0,0 +1,51 @@ +package agreements + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type State string + +const ( + StateActive State = "Active" + StateCanceled State = "Canceled" +) + +func PossibleValuesForState() []string { + return []string{ + string(StateActive), + string(StateCanceled), + } +} + +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseState(input string) (*State, error) { + vals := map[string]State{ + "active": StateActive, + "canceled": StateCanceled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := State(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_offerplan.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_offerplan.go new file mode 100644 index 000000000000..cf08432ab6d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_offerplan.go @@ -0,0 +1,142 @@ +package agreements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = OfferPlanId{} + +// OfferPlanId is a struct representing the Resource ID for a Offer Plan +type OfferPlanId struct { + SubscriptionId string + PublisherId string + OfferId string + PlanId string +} + +// NewOfferPlanID returns a new OfferPlanId struct +func NewOfferPlanID(subscriptionId string, publisherId string, offerId string, planId string) OfferPlanId { + return OfferPlanId{ + SubscriptionId: subscriptionId, + PublisherId: publisherId, + OfferId: offerId, + PlanId: planId, + } +} + +// ParseOfferPlanID parses 'input' into a OfferPlanId +func ParseOfferPlanID(input string) (*OfferPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(OfferPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := OfferPlanId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.PublisherId, ok = parsed.Parsed["publisherId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "publisherId", *parsed) + } + + if id.OfferId, ok = parsed.Parsed["offerId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "offerId", *parsed) + } + + if id.PlanId, ok = parsed.Parsed["planId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "planId", *parsed) + } + + return &id, nil +} + +// ParseOfferPlanIDInsensitively parses 'input' case-insensitively into a OfferPlanId +// note: this method should only be used for API response data and not user input +func ParseOfferPlanIDInsensitively(input string) (*OfferPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(OfferPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := OfferPlanId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.PublisherId, ok = parsed.Parsed["publisherId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "publisherId", *parsed) + } + + if id.OfferId, ok = parsed.Parsed["offerId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "offerId", *parsed) + } + + if id.PlanId, ok = parsed.Parsed["planId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "planId", *parsed) + } + + return &id, nil +} + +// ValidateOfferPlanID checks that 'input' can be parsed as a Offer Plan ID +func ValidateOfferPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseOfferPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Offer Plan ID +func (id OfferPlanId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.MarketplaceOrdering/offerTypes/virtualMachine/publishers/%s/offers/%s/plans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PublisherId, id.OfferId, id.PlanId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Offer Plan ID +func (id OfferPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMarketplaceOrdering", "Microsoft.MarketplaceOrdering", "Microsoft.MarketplaceOrdering"), + resourceids.StaticSegment("staticOfferTypes", "offerTypes", "offerTypes"), + resourceids.StaticSegment("offerType", "virtualMachine", "virtualMachine"), + resourceids.StaticSegment("staticPublishers", "publishers", "publishers"), + resourceids.UserSpecifiedSegment("publisherId", "publisherIdValue"), + resourceids.StaticSegment("staticOffers", "offers", "offers"), + resourceids.UserSpecifiedSegment("offerId", "offerIdValue"), + resourceids.StaticSegment("staticPlans", "plans", "plans"), + resourceids.UserSpecifiedSegment("planId", "planIdValue"), + } +} + +// String returns a human-readable description of this Offer Plan ID +func (id OfferPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Publisher: %q", id.PublisherId), + fmt.Sprintf("Offer: %q", id.OfferId), + fmt.Sprintf("Plan: %q", id.PlanId), + } + return fmt.Sprintf("Offer Plan (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_plan.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_plan.go new file mode 100644 index 000000000000..855bb5854088 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/id_plan.go @@ -0,0 +1,140 @@ +package agreements + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = PlanId{} + +// PlanId is a struct representing the Resource ID for a Plan +type PlanId struct { + SubscriptionId string + PublisherId string + OfferId string + PlanId string +} + +// NewPlanID returns a new PlanId struct +func NewPlanID(subscriptionId string, publisherId string, offerId string, planId string) PlanId { + return PlanId{ + SubscriptionId: subscriptionId, + PublisherId: publisherId, + OfferId: offerId, + PlanId: planId, + } +} + +// ParsePlanID parses 'input' into a PlanId +func ParsePlanID(input string) (*PlanId, error) { + parser := resourceids.NewParserFromResourceIdType(PlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PlanId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.PublisherId, ok = parsed.Parsed["publisherId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "publisherId", *parsed) + } + + if id.OfferId, ok = parsed.Parsed["offerId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "offerId", *parsed) + } + + if id.PlanId, ok = parsed.Parsed["planId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "planId", *parsed) + } + + return &id, nil +} + +// ParsePlanIDInsensitively parses 'input' case-insensitively into a PlanId +// note: this method should only be used for API response data and not user input +func ParsePlanIDInsensitively(input string) (*PlanId, error) { + parser := resourceids.NewParserFromResourceIdType(PlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PlanId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.PublisherId, ok = parsed.Parsed["publisherId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "publisherId", *parsed) + } + + if id.OfferId, ok = parsed.Parsed["offerId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "offerId", *parsed) + } + + if id.PlanId, ok = parsed.Parsed["planId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "planId", *parsed) + } + + return &id, nil +} + +// ValidatePlanID checks that 'input' can be parsed as a Plan ID +func ValidatePlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Plan ID +func (id PlanId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.MarketplaceOrdering/agreements/%s/offers/%s/plans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PublisherId, id.OfferId, id.PlanId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Plan ID +func (id PlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMarketplaceOrdering", "Microsoft.MarketplaceOrdering", "Microsoft.MarketplaceOrdering"), + resourceids.StaticSegment("staticAgreements", "agreements", "agreements"), + resourceids.UserSpecifiedSegment("publisherId", "publisherIdValue"), + resourceids.StaticSegment("staticOffers", "offers", "offers"), + resourceids.UserSpecifiedSegment("offerId", "offerIdValue"), + resourceids.StaticSegment("staticPlans", "plans", "plans"), + resourceids.UserSpecifiedSegment("planId", "planIdValue"), + } +} + +// String returns a human-readable description of this Plan ID +func (id PlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Publisher: %q", id.PublisherId), + fmt.Sprintf("Offer: %q", id.OfferId), + fmt.Sprintf("Plan: %q", id.PlanId), + } + return fmt.Sprintf("Plan (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscancel.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscancel.go new file mode 100644 index 000000000000..b57be82a15df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscancel.go @@ -0,0 +1,52 @@ +package agreements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsCancelOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OldAgreementTerms +} + +// MarketplaceAgreementsCancel ... +func (c AgreementsClient) MarketplaceAgreementsCancel(ctx context.Context, id PlanId) (result MarketplaceAgreementsCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscreate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscreate.go new file mode 100644 index 000000000000..a7c333a0128a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementscreate.go @@ -0,0 +1,56 @@ +package agreements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgreementTerms +} + +// MarketplaceAgreementsCreate ... +func (c AgreementsClient) MarketplaceAgreementsCreate(ctx context.Context, id OfferPlanId, input AgreementTerms) (result MarketplaceAgreementsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/agreements/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsget.go new file mode 100644 index 000000000000..86f30ee193c6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsget.go @@ -0,0 +1,52 @@ +package agreements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgreementTerms +} + +// MarketplaceAgreementsGet ... +func (c AgreementsClient) MarketplaceAgreementsGet(ctx context.Context, id OfferPlanId) (result MarketplaceAgreementsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/agreements/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsgetagreement.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsgetagreement.go new file mode 100644 index 000000000000..60692d0de428 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementsgetagreement.go @@ -0,0 +1,51 @@ +package agreements + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsGetAgreementOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OldAgreementTerms +} + +// MarketplaceAgreementsGetAgreement ... +func (c AgreementsClient) MarketplaceAgreementsGetAgreement(ctx context.Context, id PlanId) (result MarketplaceAgreementsGetAgreementOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementslist.go new file mode 100644 index 000000000000..110983b3f182 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementslist.go @@ -0,0 +1,53 @@ +package agreements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OldAgreementTermsList +} + +// MarketplaceAgreementsList ... +func (c AgreementsClient) MarketplaceAgreementsList(ctx context.Context, id commonids.SubscriptionId) (result MarketplaceAgreementsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MarketplaceOrdering/agreements", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementssign.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementssign.go new file mode 100644 index 000000000000..667f99a99057 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/method_marketplaceagreementssign.go @@ -0,0 +1,52 @@ +package agreements + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceAgreementsSignOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OldAgreementTerms +} + +// MarketplaceAgreementsSign ... +func (c AgreementsClient) MarketplaceAgreementsSign(ctx context.Context, id PlanId) (result MarketplaceAgreementsSignOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sign", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementproperties.go new file mode 100644 index 000000000000..e8cfb143060f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementproperties.go @@ -0,0 +1,34 @@ +package agreements + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgreementProperties struct { + Accepted *bool `json:"accepted,omitempty"` + LicenseTextLink *string `json:"licenseTextLink,omitempty"` + MarketplaceTermsLink *string `json:"marketplaceTermsLink,omitempty"` + Plan *string `json:"plan,omitempty"` + PrivacyPolicyLink *string `json:"privacyPolicyLink,omitempty"` + Product *string `json:"product,omitempty"` + Publisher *string `json:"publisher,omitempty"` + RetrieveDatetime *string `json:"retrieveDatetime,omitempty"` + Signature *string `json:"signature,omitempty"` +} + +func (o *AgreementProperties) GetRetrieveDatetimeAsTime() (*time.Time, error) { + if o.RetrieveDatetime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetrieveDatetime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AgreementProperties) SetRetrieveDatetimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetrieveDatetime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementterms.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementterms.go new file mode 100644 index 000000000000..031f90fc87f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_agreementterms.go @@ -0,0 +1,16 @@ +package agreements + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgreementTerms struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AgreementProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementproperties.go new file mode 100644 index 000000000000..9943f89574b9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementproperties.go @@ -0,0 +1,43 @@ +package agreements + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OldAgreementProperties struct { + CancelDate *string `json:"cancelDate,omitempty"` + Id *string `json:"id,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + SignDate *string `json:"signDate,omitempty"` + State *State `json:"state,omitempty"` +} + +func (o *OldAgreementProperties) GetCancelDateAsTime() (*time.Time, error) { + if o.CancelDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CancelDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *OldAgreementProperties) SetCancelDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CancelDate = &formatted +} + +func (o *OldAgreementProperties) GetSignDateAsTime() (*time.Time, error) { + if o.SignDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SignDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *OldAgreementProperties) SetSignDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SignDate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementterms.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementterms.go new file mode 100644 index 000000000000..b9299c6a38e4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementterms.go @@ -0,0 +1,11 @@ +package agreements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OldAgreementTerms struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OldAgreementProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementtermslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementtermslist.go new file mode 100644 index 000000000000..2239e659c9f4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/model_oldagreementtermslist.go @@ -0,0 +1,8 @@ +package agreements + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OldAgreementTermsList struct { + Value *[]OldAgreementTerms `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/version.go new file mode 100644 index 000000000000..e316779d39d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements/version.go @@ -0,0 +1,12 @@ +package agreements + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-01-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/agreements/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4172c2930348..209ae59a1fd2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,6 @@ github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafacto github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2021-12-01/eventgrid github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2018-06-01/hdinsight -github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/marketplaceordering github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2020-01-01/mysql github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2021-05-01/mysqlflexibleservers github.com/Azure/azure-sdk-for-go/services/preview/alertsmanagement/mgmt/2019-06-01-preview/alertsmanagement @@ -426,6 +425,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/databases github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/firewallrules github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/servers github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/virtualnetworkrules +github.com/hashicorp/go-azure-sdk/resource-manager/marketplaceordering/2021-01-01/agreements github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01 github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01/accountfilters github.com/hashicorp/go-azure-sdk/resource-manager/media/2021-11-01/accounts