From 4b761e8c5c92ab4d8226235710e1b391b4565912 Mon Sep 17 00:00:00 2001 From: JT <100274846+jiaweitao001@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:07:59 +0800 Subject: [PATCH] New Resource: `azurerm_dynatrace_monitor` (#27432) * New resources: azurerm_dynatrace_monitors, azurerm_dynatrace_tag_rules * Adding documentation * Add subcategory * Renaming parameters * change variable names * Fix acc tests * Renaming variables * fix schema * fix imports * retrigger teamcity run * rebase dynatrace * Update API * New Resource: azurerm_dynatrace_monitors * sort imports * Fix imports * Fix lint * Fix gencheck * Fix gofmt * Remove redundant condition * Address PR comments * Update docs * Update expand/flatten identity helper * Add prechecks * remove effective date, testing * modified tests, replace pointers * modified docs * upgrade vendor * fix go gen * skip tests * inclined some functions, changed docs * fix imports * update vendors * inlined values, add tracking issue * Format code to follow guidance * format acc test --- .github/labeler-issue-triage.yml | 3 + .github/labeler-pull-request-triage.yml | 5 + .teamcity/components/generated/services.kt | 1 + internal/clients/client.go | 5 + internal/provider/services.go | 2 + internal/services/dynatrace/client/client.go | 24 + .../dynatrace/dynatrace_monitors_resource.go | 382 ++++++++++ .../dynatrace_monitors_resource_test.go | 253 +++++++ internal/services/dynatrace/helper.go | 87 +++ internal/services/dynatrace/registration.go | 31 + .../dynatrace/2023-04-27/monitors/README.md | 268 +++++++ .../dynatrace/2023-04-27/monitors/client.go | 26 + .../2023-04-27/monitors/constants.go | 653 ++++++++++++++++++ .../2023-04-27/monitors/id_monitor.go | 130 ++++ .../monitors/method_createorupdate.go | 75 ++ .../2023-04-27/monitors/method_delete.go | 71 ++ .../2023-04-27/monitors/method_get.go | 53 ++ ...ethod_getmarketplacesaasresourcedetails.go | 59 ++ .../monitors/method_getmetricstatus.go | 54 ++ .../monitors/method_getssodetails.go | 58 ++ .../monitors/method_getvmhostpayload.go | 54 ++ .../monitors/method_listappservices.go | 105 +++ .../monitors/method_listbyresourcegroup.go | 106 +++ .../monitors/method_listbysubscriptionid.go | 106 +++ .../2023-04-27/monitors/method_listhosts.go | 105 +++ .../method_listlinkableenvironments.go | 105 +++ .../monitors/method_listmonitoredresources.go | 105 +++ .../2023-04-27/monitors/method_update.go | 57 ++ .../2023-04-27/monitors/model_accountinfo.go | 9 + .../monitors/model_appserviceinfo.go | 16 + .../model_dynatraceenvironmentproperties.go | 11 + .../model_dynatracesinglesignonproperties.go | 12 + .../monitors/model_environmentinfo.go | 11 + .../monitors/model_identityproperties.go | 11 + .../model_linkableenvironmentrequest.go | 10 + .../model_linkableenvironmentresponse.go | 10 + ...l_marketplacesaasresourcedetailsrequest.go | 8 + ..._marketplacesaasresourcedetailsresponse.go | 10 + .../monitors/model_metricsstatusresponse.go | 8 + .../monitors/model_monitoredresource.go | 12 + .../monitors/model_monitorproperties.go | 15 + .../monitors/model_monitorresource.go | 19 + .../monitors/model_monitorresourceupdate.go | 8 + .../2023-04-27/monitors/model_plandata.go | 29 + .../monitors/model_ssodetailsrequest.go | 8 + .../monitors/model_ssodetailsresponse.go | 12 + .../monitors/model_userassignedidentity.go | 9 + .../2023-04-27/monitors/model_userinfo.go | 12 + .../monitors/model_vmextensionpayload.go | 9 + .../2023-04-27/monitors/model_vminfo.go | 16 + .../2023-04-27/monitors/predicates.go | 129 ++++ .../dynatrace/2023-04-27/monitors/version.go | 10 + vendor/modules.txt | 1 + website/allowed-subcategories | 1 + .../docs/r/dynatrace_monitors.html.markdown | 125 ++++ 55 files changed, 3514 insertions(+) create mode 100644 internal/services/dynatrace/client/client.go create mode 100644 internal/services/dynatrace/dynatrace_monitors_resource.go create mode 100644 internal/services/dynatrace/dynatrace_monitors_resource_test.go create mode 100644 internal/services/dynatrace/helper.go create mode 100644 internal/services/dynatrace/registration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/id_monitor.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmarketplacesaasresourcedetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmetricstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getssodetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getvmhostpayload.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listappservices.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbysubscriptionid.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listhosts.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listlinkableenvironments.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listmonitoredresources.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_accountinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_appserviceinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatraceenvironmentproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatracesinglesignonproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_environmentinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_identityproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_metricsstatusresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitoredresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresourceupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_plandata.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsresponse.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userassignedidentity.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vmextensionpayload.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vminfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/version.go create mode 100644 website/docs/r/dynatrace_monitors.html.markdown diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 7a73966bed5a..cafa691fd661 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -128,6 +128,9 @@ service/dns: service/domain-services: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_active_directory_domain_service((.|\n)*)###' +service/dynatrace: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_dynatrace_monitor((.|\n)*)###' + service/elastic: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_elastic_cloud_elasticsearch((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index d330093a2f96..154f12cb7ac8 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -214,6 +214,11 @@ service/domain-services: - any-glob-to-any-file: - internal/services/domainservices/**/* +service/dynatrace: +- changed-files: + - any-glob-to-any-file: + - internal/services/dynatrace/**/* + service/elastic: - changed-files: - any-glob-to-any-file: diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 69ac1bfed318..e6d7678a75f5 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -48,6 +48,7 @@ var services = mapOf( "devtestlabs" to "Dev Test", "digitaltwins" to "Digital Twins", "domainservices" to "DomainServices", + "dynatrace" to "Dynatrace", "elastic" to "Elastic", "elasticsan" to "ElasticSan", "eventgrid" to "EventGrid", diff --git a/internal/clients/client.go b/internal/clients/client.go index fc293bd3845b..2cc0295a7ec6 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -68,6 +68,7 @@ import ( digitaltwins "github.com/hashicorp/terraform-provider-azurerm/internal/services/digitaltwins/client" dns "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/client" domainservices "github.com/hashicorp/terraform-provider-azurerm/internal/services/domainservices/client" + dynatrace "github.com/hashicorp/terraform-provider-azurerm/internal/services/dynatrace/client" elastic "github.com/hashicorp/terraform-provider-azurerm/internal/services/elastic/client" elasticsan "github.com/hashicorp/terraform-provider-azurerm/internal/services/elasticsan/client" eventgrid "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid/client" @@ -202,6 +203,7 @@ type Client struct { DigitalTwins *digitaltwins.Client Dns *dns_v2018_05_01.Client DomainServices *domainservices.Client + Dynatrace *dynatrace.Client Elastic *elastic.Client ElasticSan *elasticsan.Client EventGrid *eventgrid_v2022_06_15.Client @@ -437,6 +439,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.EventGrid, err = eventgrid.NewClient(o); err != nil { return fmt.Errorf("building clients for EventGrid: %+v", err) } + if client.Dynatrace, err = dynatrace.NewClient(o); err != nil { + return fmt.Errorf("building clients for Dynatrace: %+v", err) + } if client.Eventhub, err = eventhub.NewClient(o); err != nil { return fmt.Errorf("building clients for Eventhub: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index 7e91ce32f478..b346946a637e 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -49,6 +49,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/digitaltwins" "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns" "github.com/hashicorp/terraform-provider-azurerm/internal/services/domainservices" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/dynatrace" "github.com/hashicorp/terraform-provider-azurerm/internal/services/elastic" "github.com/hashicorp/terraform-provider-azurerm/internal/services/elasticsan" "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid" @@ -168,6 +169,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { digitaltwins.Registration{}, domainservices.Registration{}, elasticsan.Registration{}, + dynatrace.Registration{}, eventhub.Registration{}, extendedlocation.Registration{}, fluidrelay.Registration{}, diff --git a/internal/services/dynatrace/client/client.go b/internal/services/dynatrace/client/client.go new file mode 100644 index 000000000000..490443d3fb52 --- /dev/null +++ b/internal/services/dynatrace/client/client.go @@ -0,0 +1,24 @@ +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + *monitors.MonitorsClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + monitorClient, err := monitors.NewMonitorsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Dynatrace Monitor client: %+v", err) + } + o.Configure(monitorClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + MonitorsClient: monitorClient, + }, nil +} diff --git a/internal/services/dynatrace/dynatrace_monitors_resource.go b/internal/services/dynatrace/dynatrace_monitors_resource.go new file mode 100644 index 000000000000..c5f2c7b6f012 --- /dev/null +++ b/internal/services/dynatrace/dynatrace_monitors_resource.go @@ -0,0 +1,382 @@ +package dynatrace + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type MonitorsResource struct{} + +var _ sdk.ResourceWithUpdate = MonitorsResource{} + +type MonitorsResourceModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + MonitoringStatus bool `tfschema:"monitoring_enabled"` + MarketplaceSubscriptionStatus string `tfschema:"marketplace_subscription"` + Identity []identity.ModelSystemAssigned `tfschema:"identity"` + PlanData []PlanData `tfschema:"plan"` + UserInfo []UserInfo `tfschema:"user"` + Tags map[string]string `tfschema:"tags"` +} + +type PlanData struct { + BillingCycle string `tfschema:"billing_cycle"` + EffectiveDate string `tfschema:"effective_date"` + PlanDetails string `tfschema:"plan"` + UsageType string `tfschema:"usage_type"` +} + +type UserInfo struct { + Country string `tfschema:"country"` + EmailAddress string `tfschema:"email"` + FirstName string `tfschema:"first_name"` + LastName string `tfschema:"last_name"` + PhoneNumber string `tfschema:"phone_number"` +} + +func (r MonitorsResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "monitoring_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + ForceNew: true, + Default: true, + }, + + "marketplace_subscription": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(monitors.MarketplaceSubscriptionStatusActive), + string(monitors.MarketplaceSubscriptionStatusSuspended), + }, false), + }, + + "identity": commonschema.SystemAssignedIdentityRequired(), + + "plan": { + Type: pluginsdk.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + // Issue: https://github.com/Azure/azure-rest-api-specs/issues/31284 + // This should be an enum. + "billing_cycle": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "MONTHLY", + "WEEKLY", + }, false), + }, + + "plan": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + // Issue: https://github.com/Azure/azure-rest-api-specs/issues/31284 + // This should be an enum. + "usage_type": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "PAYG", + "COMMITTED", + }, false), + }, + + "effective_date": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "user": { + Type: pluginsdk.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "country": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "email": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validate.EmailAddress, + }, + + "first_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "last_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "phone_number": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + + "tags": tags.Schema(), + } +} + +func (r MonitorsResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r MonitorsResource) ModelObject() interface{} { + return &MonitorsResourceModel{} +} + +func (r MonitorsResource) ResourceType() string { + return "azurerm_dynatrace_monitor" +} + +func (r MonitorsResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Dynatrace.MonitorsClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var model MonitorsResourceModel + if err := metadata.Decode(&model); err != nil { + return err + } + + id := monitors.NewMonitorID(subscriptionId, model.ResourceGroup, model.Name) + + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + monitoringStatus := monitors.MonitoringStatusEnabled + if !model.MonitoringStatus { + monitoringStatus = monitors.MonitoringStatusDisabled + } + monitorsProps := monitors.MonitorProperties{ + MarketplaceSubscriptionStatus: pointer.To(monitors.MarketplaceSubscriptionStatus(model.MarketplaceSubscriptionStatus)), + MonitoringStatus: pointer.To(monitoringStatus), + PlanData: ExpandDynatracePlanData(model.PlanData), + UserInfo: ExpandDynatraceUserInfo(model.UserInfo), + } + + dynatraceIdentity, err := expandDynatraceIdentity(model.Identity) + if err != nil { + return fmt.Errorf("expanding identity: %+v", err) + } + + monitor := monitors.MonitorResource{ + Identity: dynatraceIdentity, + Location: model.Location, + Name: pointer.To(model.Name), + Properties: monitorsProps, + Tags: pointer.To(model.Tags), + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, monitor); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r MonitorsResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Dynatrace.MonitorsClient + id, err := monitors.ParseMonitorID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("reading %s: %+v", id, err) + } + + if model := resp.Model; model != nil { + props := model.Properties + identityProps, err := flattenDynatraceIdentity(model.Identity) + if err != nil { + return fmt.Errorf("flattening identity: %+v", err) + } + monitoringStatus := true + if *props.MonitoringStatus == monitors.MonitoringStatusDisabled { + monitoringStatus = false + } + + state := MonitorsResourceModel{ + Name: id.MonitorName, + ResourceGroup: id.ResourceGroupName, + Location: model.Location, + MonitoringStatus: monitoringStatus, + MarketplaceSubscriptionStatus: string(*props.MarketplaceSubscriptionStatus), + Identity: identityProps, + PlanData: FlattenDynatracePlanData(props.PlanData), + UserInfo: FlattenDynatraceUserInfo(metadata.ResourceData.Get("user").([]interface{})), + } + + if model.Tags != nil { + state.Tags = *model.Tags + } + + return metadata.Encode(&state) + } + return nil + }, + } +} + +func (r MonitorsResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Dynatrace.MonitorsClient + id, err := monitors.ParseMonitorID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + metadata.Logger.Infof("deleting %s", *id) + + if resp, err := client.Delete(ctx, *id); err != nil { + if !response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + } + return nil + }, + } +} + +func (r MonitorsResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return monitors.ValidateMonitorID +} + +func (r MonitorsResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Dynatrace.MonitorsClient + id, err := monitors.ParseMonitorID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var state MonitorsResourceModel + if err := metadata.Decode(&state); err != nil { + return fmt.Errorf("decoding %+v", err) + } + + if metadata.ResourceData.HasChange("tags") { + props := monitors.MonitorResourceUpdate{ + Tags: pointer.To(state.Tags), + } + + if _, err := client.Update(ctx, *id, props); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + } + + return nil + }, + } +} + +func expandDynatraceIdentity(input []identity.ModelSystemAssigned) (*monitors.IdentityProperties, error) { + config, err := identity.ExpandSystemAssignedFromModel(input) + if err != nil { + return nil, err + } + + if config.Type == identity.TypeNone { + return pointer.To(monitors.IdentityProperties{}), nil + } + + dynatraceIdentity := monitors.IdentityProperties{ + Type: monitors.ManagedIdentityType(config.Type), + } + + return pointer.To(dynatraceIdentity), nil +} + +func flattenDynatraceIdentity(input *monitors.IdentityProperties) ([]identity.ModelSystemAssigned, error) { + if input == nil { + return nil, fmt.Errorf("flattening Dynatrace identity: input is nil") + } + var identityProp identity.ModelSystemAssigned + + identityProp.Type = identity.Type(input.Type) + + if input.PrincipalId != nil { + identityProp.PrincipalId = pointer.From(input.PrincipalId) + } + + if input.TenantId != nil { + identityProp.TenantId = pointer.From(input.TenantId) + } + + return []identity.ModelSystemAssigned{ + identityProp, + }, nil +} diff --git a/internal/services/dynatrace/dynatrace_monitors_resource_test.go b/internal/services/dynatrace/dynatrace_monitors_resource_test.go new file mode 100644 index 000000000000..8741d6060d2b --- /dev/null +++ b/internal/services/dynatrace/dynatrace_monitors_resource_test.go @@ -0,0 +1,253 @@ +package dynatrace_test + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors" + "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/tf/pluginsdk" +) + +type dynatraceInfo struct { + UserCountry string + UserEmail string + UserFirstName string + UserLastName string + UserPhoneNumber string +} + +type MonitorsResource struct { + dynatraceInfo dynatraceInfo +} + +func NewDynatraceMonitorResource() MonitorsResource { + return MonitorsResource{ + dynatraceInfo: dynatraceInfo{ + UserCountry: os.Getenv("DYNATRACE_USER_COUNTRY"), + UserEmail: os.Getenv("DYNATRACE_USER_EMAIL"), + UserFirstName: os.Getenv("DYNATRACE_USER_FIRST_NAME"), + UserLastName: os.Getenv("DYNATRACE_USER_LAST_NAME"), + UserPhoneNumber: os.Getenv("DYNATRACE_USER_PHONE_NUMBER"), + }, + } +} + +func TestAccDynatraceMonitor_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dynatrace_monitor", "test") + r := MonitorsResource{} + r.preCheck(t) + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + + data.ImportStep("user"), + }) +} + +func TestAccDynatraceMonitor_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dynatrace_monitor", "test") + r := MonitorsResource{} + r.preCheck(t) + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("user"), + { + Config: r.updated(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("user"), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("user"), + }) +} + +func TestAccDynatraceMonitor_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dynatrace_monitor", "test") + r := MonitorsResource{} + r.preCheck(t) + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (r MonitorsResource) preCheck(t *testing.T) { + if r.dynatraceInfo.UserCountry == "" { + t.Skipf("DYNATRACE_USER_COUNTRY must be set for acceptance tests") + } + if r.dynatraceInfo.UserEmail == "" { + t.Skipf("DYNATRACE_USER_EMAIL must be set for acceptance tests") + } + if r.dynatraceInfo.UserFirstName == "" { + t.Skipf("DYNATRACE_USER_FIRST_NAME must be set for acceptance tests") + } + if r.dynatraceInfo.UserLastName == "" { + t.Skipf("DYNATRACE_USER_LAST_NAME must be set for acceptance tests") + } + if r.dynatraceInfo.UserPhoneNumber == "" { + t.Skipf("DYNATRACE_USER_PHONE_NUMBER must be set for acceptance tests") + } +} + +func (r MonitorsResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := monitors.ParseMonitorID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.Dynatrace.MonitorsClient.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return pointer.To(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + return pointer.To(true), nil +} + +func (r MonitorsResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_dynatrace_monitor" "test" { + name = "acctestacc%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + marketplace_subscription = "Active" + + identity { + type = "SystemAssigned" + } + + user { + first_name = "%s" + last_name = "%s" + email = "%s" + phone_number = "%s" + country = "%s" + } + + plan { + usage_type = "COMMITTED" + billing_cycle = "MONTHLY" + plan = "azureportalintegration_privatepreview@TIDgmz7xq9ge3py" + } + + tags = { + environment = "Dev" + } +} +`, template, data.RandomInteger, r.dynatraceInfo.UserFirstName, r.dynatraceInfo.UserLastName, r.dynatraceInfo.UserEmail, r.dynatraceInfo.UserPhoneNumber, r.dynatraceInfo.UserCountry) +} + +func (r MonitorsResource) updated(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_dynatrace_monitor" "test" { + name = "acctestacc%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + marketplace_subscription = "Active" + + identity { + type = "SystemAssigned" + } + user { + first_name = "%s" + last_name = "%s" + email = "%s" + phone_number = "%s" + country = "%s" + } + + plan { + usage_type = "COMMITTED" + billing_cycle = "MONTHLY" + plan = "azureportalintegration_privatepreview@TIDgmz7xq9ge3py" + } + + tags = { + environment = "Prod" + test = "Patch" + } +} +`, template, data.RandomInteger, r.dynatraceInfo.UserFirstName, r.dynatraceInfo.UserLastName, r.dynatraceInfo.UserEmail, r.dynatraceInfo.UserPhoneNumber, r.dynatraceInfo.UserCountry) +} + +func (r MonitorsResource) requiresImport(data acceptance.TestData) string { + template := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_dynatrace_monitor" "import" { + name = azurerm_dynatrace_monitor.test.name + resource_group_name = azurerm_dynatrace_monitor.test.resource_group_name + location = azurerm_dynatrace_monitor.test.location + marketplace_subscription = azurerm_dynatrace_monitor.test.marketplace_subscription + + identity { + type = azurerm_dynatrace_monitor.test.identity.0.type + } + user { + first_name = azurerm_dynatrace_monitor.test.user.0.first_name + last_name = azurerm_dynatrace_monitor.test.user.0.last_name + email = azurerm_dynatrace_monitor.test.user.0.email + phone_number = azurerm_dynatrace_monitor.test.user.0.phone_number + country = azurerm_dynatrace_monitor.test.user.0.country + } + + plan { + usage_type = azurerm_dynatrace_monitor.test.plan.0.usage_type + billing_cycle = azurerm_dynatrace_monitor.test.plan.0.billing_cycle + plan = azurerm_dynatrace_monitor.test.plan.0.plan + } +} +`, template) +} + +func (r MonitorsResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} +`, data.RandomInteger, "eastus2euap", data.RandomString) +} diff --git a/internal/services/dynatrace/helper.go b/internal/services/dynatrace/helper.go new file mode 100644 index 000000000000..802dc4531cba --- /dev/null +++ b/internal/services/dynatrace/helper.go @@ -0,0 +1,87 @@ +package dynatrace + +import ( + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors" +) + +func ExpandDynatracePlanData(input []PlanData) *monitors.PlanData { + if len(input) == 0 { + return nil + } + v := input[0] + + return pointer.To(monitors.PlanData{ + BillingCycle: &v.BillingCycle, + PlanDetails: &v.PlanDetails, + UsageType: &v.UsageType, + }) +} + +func ExpandDynatraceUserInfo(input []UserInfo) *monitors.UserInfo { + if len(input) == 0 { + return nil + } + v := input[0] + + return pointer.To(monitors.UserInfo{ + Country: pointer.To(v.Country), + EmailAddress: pointer.To(v.EmailAddress), + FirstName: pointer.To(v.FirstName), + LastName: pointer.To(v.LastName), + PhoneNumber: pointer.To(v.PhoneNumber), + }) +} + +func FlattenDynatracePlanData(input *monitors.PlanData) []PlanData { + if input == nil { + return []PlanData{} + } + + var billingCycle string + var effectiveDate string + var planDetails string + var usageType string + + if input.BillingCycle != nil { + billingCycle = pointer.From(input.BillingCycle) + } + + if input.EffectiveDate != nil { + effectiveDate = pointer.From(input.EffectiveDate) + } + + if input.PlanDetails != nil { + planDetails = pointer.From(input.PlanDetails) + } + + if input.UsageType != nil { + usageType = pointer.From(input.UsageType) + } + + return []PlanData{ + { + BillingCycle: billingCycle, + EffectiveDate: effectiveDate, + PlanDetails: planDetails, + UsageType: usageType, + }, + } +} + +func FlattenDynatraceUserInfo(input []interface{}) []UserInfo { + if len(input) == 0 { + return []UserInfo{} + } + + v := input[0].(map[string]interface{}) + return []UserInfo{ + { + Country: v["country"].(string), + EmailAddress: v["email"].(string), + FirstName: v["first_name"].(string), + LastName: v["last_name"].(string), + PhoneNumber: v["phone_number"].(string), + }, + } +} diff --git a/internal/services/dynatrace/registration.go b/internal/services/dynatrace/registration.go new file mode 100644 index 000000000000..56751b6efc68 --- /dev/null +++ b/internal/services/dynatrace/registration.go @@ -0,0 +1,31 @@ +package dynatrace + +import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + +type Registration struct{} + +var _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} + +func (r Registration) AssociatedGitHubLabel() string { + return "service/dynatrace" +} + +func (r Registration) Name() string { + return "Dynatrace" +} + +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + MonitorsResource{}, + } +} + +func (r Registration) WebsiteCategories() []string { + return []string{ + "Dynatrace", + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/README.md new file mode 100644 index 000000000000..47d17506a63e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/README.md @@ -0,0 +1,268 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors` Documentation + +The `monitors` SDK allows for interaction with Azure Resource Manager `dynatrace` (API Version `2023-04-27`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors" +``` + + +### Client Initialization + +```go +client := monitors.NewMonitorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MonitorsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +payload := monitors.MonitorResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MonitorsClient.Delete` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MonitorsClient.Get` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MonitorsClient.GetMarketplaceSaaSResourceDetails` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := monitors.MarketplaceSaaSResourceDetailsRequest{ + // ... +} + + +read, err := client.GetMarketplaceSaaSResourceDetails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MonitorsClient.GetMetricStatus` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +read, err := client.GetMetricStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MonitorsClient.GetSSODetails` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +payload := monitors.SSODetailsRequest{ + // ... +} + + +read, err := client.GetSSODetails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MonitorsClient.GetVMHostPayload` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +read, err := client.GetVMHostPayload(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MonitorsClient.ListAppServices` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +// alternatively `client.ListAppServices(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServicesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.ListBySubscriptionId` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscriptionId(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionIdComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.ListHosts` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +// alternatively `client.ListHosts(ctx, id)` can be used to do batched pagination +items, err := client.ListHostsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.ListLinkableEnvironments` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +payload := monitors.LinkableEnvironmentRequest{ + // ... +} + + +// alternatively `client.ListLinkableEnvironments(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListLinkableEnvironmentsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.ListMonitoredResources` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +// alternatively `client.ListMonitoredResources(ctx, id)` can be used to do batched pagination +items, err := client.ListMonitoredResourcesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MonitorsClient.Update` + +```go +ctx := context.TODO() +id := monitors.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName") + +payload := monitors.MonitorResourceUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +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/dynatrace/2023-04-27/monitors/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/client.go new file mode 100644 index 000000000000..da8f22135b82 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/client.go @@ -0,0 +1,26 @@ +package monitors + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "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 MonitorsClient struct { + Client *resourcemanager.Client +} + +func NewMonitorsClientWithBaseURI(sdkApi sdkEnv.Api) (*MonitorsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "monitors", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MonitorsClient: %+v", err) + } + + return &MonitorsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/constants.go new file mode 100644 index 000000000000..8b1f3f66c1c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/constants.go @@ -0,0 +1,653 @@ +package monitors + +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 AutoUpdateSetting string + +const ( + AutoUpdateSettingDISABLED AutoUpdateSetting = "DISABLED" + AutoUpdateSettingENABLED AutoUpdateSetting = "ENABLED" +) + +func PossibleValuesForAutoUpdateSetting() []string { + return []string{ + string(AutoUpdateSettingDISABLED), + string(AutoUpdateSettingENABLED), + } +} + +func (s *AutoUpdateSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoUpdateSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoUpdateSetting(input string) (*AutoUpdateSetting, error) { + vals := map[string]AutoUpdateSetting{ + "disabled": AutoUpdateSettingDISABLED, + "enabled": AutoUpdateSettingENABLED, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoUpdateSetting(input) + return &out, nil +} + +type AvailabilityState string + +const ( + AvailabilityStateCRASHED AvailabilityState = "CRASHED" + AvailabilityStateLOST AvailabilityState = "LOST" + AvailabilityStateMONITORED AvailabilityState = "MONITORED" + AvailabilityStatePREMONITORED AvailabilityState = "PRE_MONITORED" + AvailabilityStateSHUTDOWN AvailabilityState = "SHUTDOWN" + AvailabilityStateUNEXPECTEDSHUTDOWN AvailabilityState = "UNEXPECTED_SHUTDOWN" + AvailabilityStateUNKNOWN AvailabilityState = "UNKNOWN" + AvailabilityStateUNMONITORED AvailabilityState = "UNMONITORED" +) + +func PossibleValuesForAvailabilityState() []string { + return []string{ + string(AvailabilityStateCRASHED), + string(AvailabilityStateLOST), + string(AvailabilityStateMONITORED), + string(AvailabilityStatePREMONITORED), + string(AvailabilityStateSHUTDOWN), + string(AvailabilityStateUNEXPECTEDSHUTDOWN), + string(AvailabilityStateUNKNOWN), + string(AvailabilityStateUNMONITORED), + } +} + +func (s *AvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAvailabilityState(input string) (*AvailabilityState, error) { + vals := map[string]AvailabilityState{ + "crashed": AvailabilityStateCRASHED, + "lost": AvailabilityStateLOST, + "monitored": AvailabilityStateMONITORED, + "pre_monitored": AvailabilityStatePREMONITORED, + "shutdown": AvailabilityStateSHUTDOWN, + "unexpected_shutdown": AvailabilityStateUNEXPECTEDSHUTDOWN, + "unknown": AvailabilityStateUNKNOWN, + "unmonitored": AvailabilityStateUNMONITORED, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AvailabilityState(input) + return &out, nil +} + +type LiftrResourceCategories string + +const ( + LiftrResourceCategoriesMonitorLogs LiftrResourceCategories = "MonitorLogs" + LiftrResourceCategoriesUnknown LiftrResourceCategories = "Unknown" +) + +func PossibleValuesForLiftrResourceCategories() []string { + return []string{ + string(LiftrResourceCategoriesMonitorLogs), + string(LiftrResourceCategoriesUnknown), + } +} + +func (s *LiftrResourceCategories) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLiftrResourceCategories(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLiftrResourceCategories(input string) (*LiftrResourceCategories, error) { + vals := map[string]LiftrResourceCategories{ + "monitorlogs": LiftrResourceCategoriesMonitorLogs, + "unknown": LiftrResourceCategoriesUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LiftrResourceCategories(input) + return &out, nil +} + +type LogModule string + +const ( + LogModuleDISABLED LogModule = "DISABLED" + LogModuleENABLED LogModule = "ENABLED" +) + +func PossibleValuesForLogModule() []string { + return []string{ + string(LogModuleDISABLED), + string(LogModuleENABLED), + } +} + +func (s *LogModule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogModule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogModule(input string) (*LogModule, error) { + vals := map[string]LogModule{ + "disabled": LogModuleDISABLED, + "enabled": LogModuleENABLED, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogModule(input) + return &out, nil +} + +type ManagedIdentityType string + +const ( + ManagedIdentityTypeSystemAndUserAssigned ManagedIdentityType = "SystemAndUserAssigned" + ManagedIdentityTypeSystemAssigned ManagedIdentityType = "SystemAssigned" + ManagedIdentityTypeUserAssigned ManagedIdentityType = "UserAssigned" +) + +func PossibleValuesForManagedIdentityType() []string { + return []string{ + string(ManagedIdentityTypeSystemAndUserAssigned), + string(ManagedIdentityTypeSystemAssigned), + string(ManagedIdentityTypeUserAssigned), + } +} + +func (s *ManagedIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedIdentityType(input string) (*ManagedIdentityType, error) { + vals := map[string]ManagedIdentityType{ + "systemanduserassigned": ManagedIdentityTypeSystemAndUserAssigned, + "systemassigned": ManagedIdentityTypeSystemAssigned, + "userassigned": ManagedIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedIdentityType(input) + return &out, nil +} + +type MarketplaceSubscriptionStatus string + +const ( + MarketplaceSubscriptionStatusActive MarketplaceSubscriptionStatus = "Active" + MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" +) + +func PossibleValuesForMarketplaceSubscriptionStatus() []string { + return []string{ + string(MarketplaceSubscriptionStatusActive), + string(MarketplaceSubscriptionStatusSuspended), + } +} + +func (s *MarketplaceSubscriptionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMarketplaceSubscriptionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMarketplaceSubscriptionStatus(input string) (*MarketplaceSubscriptionStatus, error) { + vals := map[string]MarketplaceSubscriptionStatus{ + "active": MarketplaceSubscriptionStatusActive, + "suspended": MarketplaceSubscriptionStatusSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MarketplaceSubscriptionStatus(input) + return &out, nil +} + +type MonitoringStatus string + +const ( + MonitoringStatusDisabled MonitoringStatus = "Disabled" + MonitoringStatusEnabled MonitoringStatus = "Enabled" +) + +func PossibleValuesForMonitoringStatus() []string { + return []string{ + string(MonitoringStatusDisabled), + string(MonitoringStatusEnabled), + } +} + +func (s *MonitoringStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringStatus(input string) (*MonitoringStatus, error) { + vals := map[string]MonitoringStatus{ + "disabled": MonitoringStatusDisabled, + "enabled": MonitoringStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringStatus(input) + return &out, nil +} + +type MonitoringType string + +const ( + MonitoringTypeCLOUDINFRASTRUCTURE MonitoringType = "CLOUD_INFRASTRUCTURE" + MonitoringTypeFULLSTACK MonitoringType = "FULL_STACK" +) + +func PossibleValuesForMonitoringType() []string { + return []string{ + string(MonitoringTypeCLOUDINFRASTRUCTURE), + string(MonitoringTypeFULLSTACK), + } +} + +func (s *MonitoringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringType(input string) (*MonitoringType, error) { + vals := map[string]MonitoringType{ + "cloud_infrastructure": MonitoringTypeCLOUDINFRASTRUCTURE, + "full_stack": MonitoringTypeFULLSTACK, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "notspecified": ProvisioningStateNotSpecified, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SSOStatus string + +const ( + SSOStatusDisabled SSOStatus = "Disabled" + SSOStatusEnabled SSOStatus = "Enabled" +) + +func PossibleValuesForSSOStatus() []string { + return []string{ + string(SSOStatusDisabled), + string(SSOStatusEnabled), + } +} + +func (s *SSOStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSSOStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSSOStatus(input string) (*SSOStatus, error) { + vals := map[string]SSOStatus{ + "disabled": SSOStatusDisabled, + "enabled": SSOStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SSOStatus(input) + return &out, nil +} + +type SendingLogsStatus string + +const ( + SendingLogsStatusDisabled SendingLogsStatus = "Disabled" + SendingLogsStatusEnabled SendingLogsStatus = "Enabled" +) + +func PossibleValuesForSendingLogsStatus() []string { + return []string{ + string(SendingLogsStatusDisabled), + string(SendingLogsStatusEnabled), + } +} + +func (s *SendingLogsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendingLogsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendingLogsStatus(input string) (*SendingLogsStatus, error) { + vals := map[string]SendingLogsStatus{ + "disabled": SendingLogsStatusDisabled, + "enabled": SendingLogsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendingLogsStatus(input) + return &out, nil +} + +type SendingMetricsStatus string + +const ( + SendingMetricsStatusDisabled SendingMetricsStatus = "Disabled" + SendingMetricsStatusEnabled SendingMetricsStatus = "Enabled" +) + +func PossibleValuesForSendingMetricsStatus() []string { + return []string{ + string(SendingMetricsStatusDisabled), + string(SendingMetricsStatusEnabled), + } +} + +func (s *SendingMetricsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSendingMetricsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSendingMetricsStatus(input string) (*SendingMetricsStatus, error) { + vals := map[string]SendingMetricsStatus{ + "disabled": SendingMetricsStatusDisabled, + "enabled": SendingMetricsStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SendingMetricsStatus(input) + return &out, nil +} + +type SingleSignOnStates string + +const ( + SingleSignOnStatesDisable SingleSignOnStates = "Disable" + SingleSignOnStatesEnable SingleSignOnStates = "Enable" + SingleSignOnStatesExisting SingleSignOnStates = "Existing" + SingleSignOnStatesInitial SingleSignOnStates = "Initial" +) + +func PossibleValuesForSingleSignOnStates() []string { + return []string{ + string(SingleSignOnStatesDisable), + string(SingleSignOnStatesEnable), + string(SingleSignOnStatesExisting), + string(SingleSignOnStatesInitial), + } +} + +func (s *SingleSignOnStates) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSingleSignOnStates(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSingleSignOnStates(input string) (*SingleSignOnStates, error) { + vals := map[string]SingleSignOnStates{ + "disable": SingleSignOnStatesDisable, + "enable": SingleSignOnStatesEnable, + "existing": SingleSignOnStatesExisting, + "initial": SingleSignOnStatesInitial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SingleSignOnStates(input) + return &out, nil +} + +type UpdateStatus string + +const ( + UpdateStatusINCOMPATIBLE UpdateStatus = "INCOMPATIBLE" + UpdateStatusOUTDATED UpdateStatus = "OUTDATED" + UpdateStatusSCHEDULED UpdateStatus = "SCHEDULED" + UpdateStatusSUPPRESSED UpdateStatus = "SUPPRESSED" + UpdateStatusUNKNOWN UpdateStatus = "UNKNOWN" + UpdateStatusUPDATEINPROGRESS UpdateStatus = "UPDATE_IN_PROGRESS" + UpdateStatusUPDATEPENDING UpdateStatus = "UPDATE_PENDING" + UpdateStatusUPDATEPROBLEM UpdateStatus = "UPDATE_PROBLEM" + UpdateStatusUPTwoDATE UpdateStatus = "UP2DATE" +) + +func PossibleValuesForUpdateStatus() []string { + return []string{ + string(UpdateStatusINCOMPATIBLE), + string(UpdateStatusOUTDATED), + string(UpdateStatusSCHEDULED), + string(UpdateStatusSUPPRESSED), + string(UpdateStatusUNKNOWN), + string(UpdateStatusUPDATEINPROGRESS), + string(UpdateStatusUPDATEPENDING), + string(UpdateStatusUPDATEPROBLEM), + string(UpdateStatusUPTwoDATE), + } +} + +func (s *UpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpdateStatus(input string) (*UpdateStatus, error) { + vals := map[string]UpdateStatus{ + "incompatible": UpdateStatusINCOMPATIBLE, + "outdated": UpdateStatusOUTDATED, + "scheduled": UpdateStatusSCHEDULED, + "suppressed": UpdateStatusSUPPRESSED, + "unknown": UpdateStatusUNKNOWN, + "update_in_progress": UpdateStatusUPDATEINPROGRESS, + "update_pending": UpdateStatusUPDATEPENDING, + "update_problem": UpdateStatusUPDATEPROBLEM, + "up2date": UpdateStatusUPTwoDATE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpdateStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/id_monitor.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/id_monitor.go new file mode 100644 index 000000000000..f8d976b7b3fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/id_monitor.go @@ -0,0 +1,130 @@ +package monitors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&MonitorId{}) +} + +var _ resourceids.ResourceId = &MonitorId{} + +// MonitorId is a struct representing the Resource ID for a Monitor +type MonitorId struct { + SubscriptionId string + ResourceGroupName string + MonitorName string +} + +// NewMonitorID returns a new MonitorId struct +func NewMonitorID(subscriptionId string, resourceGroupName string, monitorName string) MonitorId { + return MonitorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MonitorName: monitorName, + } +} + +// ParseMonitorID parses 'input' into a MonitorId +func ParseMonitorID(input string) (*MonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MonitorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMonitorIDInsensitively parses 'input' case-insensitively into a MonitorId +// note: this method should only be used for API response data and not user input +func ParseMonitorIDInsensitively(input string) (*MonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(&MonitorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MonitorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MonitorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MonitorName, ok = input.Parsed["monitorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "monitorName", input) + } + + return nil +} + +// ValidateMonitorID checks that 'input' can be parsed as a Monitor ID +func ValidateMonitorID(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 := ParseMonitorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Monitor ID +func (id MonitorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Dynatrace.Observability/monitors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MonitorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Monitor ID +func (id MonitorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticDynatraceObservability", "Dynatrace.Observability", "Dynatrace.Observability"), + resourceids.StaticSegment("staticMonitors", "monitors", "monitors"), + resourceids.UserSpecifiedSegment("monitorName", "monitorName"), + } +} + +// String returns a human-readable description of this Monitor ID +func (id MonitorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Monitor Name: %q", id.MonitorName), + } + return fmt.Sprintf("Monitor (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_createorupdate.go new file mode 100644 index 000000000000..0ba92558937a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_createorupdate.go @@ -0,0 +1,75 @@ +package monitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MonitorResource +} + +// CreateOrUpdate ... +func (c MonitorsClient) CreateOrUpdate(ctx context.Context, id MonitorId, input MonitorResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c MonitorsClient) CreateOrUpdateThenPoll(ctx context.Context, id MonitorId, input MonitorResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_delete.go new file mode 100644 index 000000000000..ed121cfa76fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_delete.go @@ -0,0 +1,71 @@ +package monitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MonitorsClient) Delete(ctx context.Context, id MonitorId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c MonitorsClient) DeleteThenPoll(ctx context.Context, id MonitorId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_get.go new file mode 100644 index 000000000000..f5544383fcf9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_get.go @@ -0,0 +1,53 @@ +package monitors + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MonitorResource +} + +// Get ... +func (c MonitorsClient) Get(ctx context.Context, id MonitorId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + 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 + } + + var model MonitorResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmarketplacesaasresourcedetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmarketplacesaasresourcedetails.go new file mode 100644 index 000000000000..40e8b2921624 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmarketplacesaasresourcedetails.go @@ -0,0 +1,59 @@ +package monitors + +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 GetMarketplaceSaaSResourceDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MarketplaceSaaSResourceDetailsResponse +} + +// GetMarketplaceSaaSResourceDetails ... +func (c MonitorsClient) GetMarketplaceSaaSResourceDetails(ctx context.Context, id commonids.SubscriptionId, input MarketplaceSaaSResourceDetailsRequest) (result GetMarketplaceSaaSResourceDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Dynatrace.Observability/getMarketplaceSaaSResourceDetails", 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 + } + + var model MarketplaceSaaSResourceDetailsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmetricstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmetricstatus.go new file mode 100644 index 000000000000..7af50028340b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getmetricstatus.go @@ -0,0 +1,54 @@ +package monitors + +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 GetMetricStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricsStatusResponse +} + +// GetMetricStatus ... +func (c MonitorsClient) GetMetricStatus(ctx context.Context, id MonitorId) (result GetMetricStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getMetricStatus", 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 + } + + var model MetricsStatusResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getssodetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getssodetails.go new file mode 100644 index 000000000000..517d1f103cef --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getssodetails.go @@ -0,0 +1,58 @@ +package monitors + +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 GetSSODetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SSODetailsResponse +} + +// GetSSODetails ... +func (c MonitorsClient) GetSSODetails(ctx context.Context, id MonitorId, input SSODetailsRequest) (result GetSSODetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getSSODetails", 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 + } + + var model SSODetailsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getvmhostpayload.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getvmhostpayload.go new file mode 100644 index 000000000000..9e78d397dedd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_getvmhostpayload.go @@ -0,0 +1,54 @@ +package monitors + +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 GetVMHostPayloadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VMExtensionPayload +} + +// GetVMHostPayload ... +func (c MonitorsClient) GetVMHostPayload(ctx context.Context, id MonitorId) (result GetVMHostPayloadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getVMHostPayload", 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 + } + + var model VMExtensionPayload + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listappservices.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listappservices.go new file mode 100644 index 000000000000..6802f73d80ac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listappservices.go @@ -0,0 +1,105 @@ +package monitors + +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 ListAppServicesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceInfo +} + +type ListAppServicesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceInfo +} + +type ListAppServicesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAppServicesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAppServices ... +func (c MonitorsClient) ListAppServices(ctx context.Context, id MonitorId) (result ListAppServicesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAppServicesCustomPager{}, + Path: fmt.Sprintf("%s/listAppServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServicesComplete retrieves all the results into a single object +func (c MonitorsClient) ListAppServicesComplete(ctx context.Context, id MonitorId) (ListAppServicesCompleteResult, error) { + return c.ListAppServicesCompleteMatchingPredicate(ctx, id, AppServiceInfoOperationPredicate{}) +} + +// ListAppServicesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListAppServicesCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate AppServiceInfoOperationPredicate) (result ListAppServicesCompleteResult, err error) { + items := make([]AppServiceInfo, 0) + + resp, err := c.ListAppServices(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAppServicesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbyresourcegroup.go new file mode 100644 index 000000000000..1f16f7513cb7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package monitors + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MonitorResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []MonitorResource +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c MonitorsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Dynatrace.Observability/monitors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MonitorResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c MonitorsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, MonitorResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate MonitorResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]MonitorResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbysubscriptionid.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbysubscriptionid.go new file mode 100644 index 000000000000..f1b3eb5736dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listbysubscriptionid.go @@ -0,0 +1,106 @@ +package monitors + +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 ListBySubscriptionIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MonitorResource +} + +type ListBySubscriptionIdCompleteResult struct { + LatestHttpResponse *http.Response + Items []MonitorResource +} + +type ListBySubscriptionIdCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionIdCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscriptionId ... +func (c MonitorsClient) ListBySubscriptionId(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionIdCustomPager{}, + Path: fmt.Sprintf("%s/providers/Dynatrace.Observability/monitors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MonitorResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionIdComplete retrieves all the results into a single object +func (c MonitorsClient) ListBySubscriptionIdComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionIdCompleteResult, error) { + return c.ListBySubscriptionIdCompleteMatchingPredicate(ctx, id, MonitorResourceOperationPredicate{}) +} + +// ListBySubscriptionIdCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListBySubscriptionIdCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate MonitorResourceOperationPredicate) (result ListBySubscriptionIdCompleteResult, err error) { + items := make([]MonitorResource, 0) + + resp, err := c.ListBySubscriptionId(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionIdCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listhosts.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listhosts.go new file mode 100644 index 000000000000..e4352ba0ab25 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listhosts.go @@ -0,0 +1,105 @@ +package monitors + +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 ListHostsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VMInfo +} + +type ListHostsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VMInfo +} + +type ListHostsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHosts ... +func (c MonitorsClient) ListHosts(ctx context.Context, id MonitorId) (result ListHostsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListHostsCustomPager{}, + Path: fmt.Sprintf("%s/listHosts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VMInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostsComplete retrieves all the results into a single object +func (c MonitorsClient) ListHostsComplete(ctx context.Context, id MonitorId) (ListHostsCompleteResult, error) { + return c.ListHostsCompleteMatchingPredicate(ctx, id, VMInfoOperationPredicate{}) +} + +// ListHostsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListHostsCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate VMInfoOperationPredicate) (result ListHostsCompleteResult, err error) { + items := make([]VMInfo, 0) + + resp, err := c.ListHosts(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listlinkableenvironments.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listlinkableenvironments.go new file mode 100644 index 000000000000..d003433e729c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listlinkableenvironments.go @@ -0,0 +1,105 @@ +package monitors + +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 ListLinkableEnvironmentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LinkableEnvironmentResponse +} + +type ListLinkableEnvironmentsCompleteResult struct { + LatestHttpResponse *http.Response + Items []LinkableEnvironmentResponse +} + +type ListLinkableEnvironmentsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListLinkableEnvironmentsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListLinkableEnvironments ... +func (c MonitorsClient) ListLinkableEnvironments(ctx context.Context, id MonitorId, input LinkableEnvironmentRequest) (result ListLinkableEnvironmentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListLinkableEnvironmentsCustomPager{}, + Path: fmt.Sprintf("%s/listLinkableEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LinkableEnvironmentResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListLinkableEnvironmentsComplete retrieves all the results into a single object +func (c MonitorsClient) ListLinkableEnvironmentsComplete(ctx context.Context, id MonitorId, input LinkableEnvironmentRequest) (ListLinkableEnvironmentsCompleteResult, error) { + return c.ListLinkableEnvironmentsCompleteMatchingPredicate(ctx, id, input, LinkableEnvironmentResponseOperationPredicate{}) +} + +// ListLinkableEnvironmentsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListLinkableEnvironmentsCompleteMatchingPredicate(ctx context.Context, id MonitorId, input LinkableEnvironmentRequest, predicate LinkableEnvironmentResponseOperationPredicate) (result ListLinkableEnvironmentsCompleteResult, err error) { + items := make([]LinkableEnvironmentResponse, 0) + + resp, err := c.ListLinkableEnvironments(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListLinkableEnvironmentsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listmonitoredresources.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listmonitoredresources.go new file mode 100644 index 000000000000..d0bd5640be23 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_listmonitoredresources.go @@ -0,0 +1,105 @@ +package monitors + +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 ListMonitoredResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MonitoredResource +} + +type ListMonitoredResourcesCompleteResult struct { + LatestHttpResponse *http.Response + Items []MonitoredResource +} + +type ListMonitoredResourcesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMonitoredResourcesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMonitoredResources ... +func (c MonitorsClient) ListMonitoredResources(ctx context.Context, id MonitorId) (result ListMonitoredResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListMonitoredResourcesCustomPager{}, + Path: fmt.Sprintf("%s/listMonitoredResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MonitoredResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMonitoredResourcesComplete retrieves all the results into a single object +func (c MonitorsClient) ListMonitoredResourcesComplete(ctx context.Context, id MonitorId) (ListMonitoredResourcesCompleteResult, error) { + return c.ListMonitoredResourcesCompleteMatchingPredicate(ctx, id, MonitoredResourceOperationPredicate{}) +} + +// ListMonitoredResourcesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MonitorsClient) ListMonitoredResourcesCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate MonitoredResourceOperationPredicate) (result ListMonitoredResourcesCompleteResult, err error) { + items := make([]MonitoredResource, 0) + + resp, err := c.ListMonitoredResources(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMonitoredResourcesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_update.go new file mode 100644 index 000000000000..c93b0c76d999 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/method_update.go @@ -0,0 +1,57 @@ +package monitors + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MonitorResource +} + +// Update ... +func (c MonitorsClient) Update(ctx context.Context, id MonitorId, input MonitorResourceUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: 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 + } + + var model MonitorResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_accountinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_accountinfo.go new file mode 100644 index 000000000000..ea70e1e2e688 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_accountinfo.go @@ -0,0 +1,9 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountInfo struct { + AccountId *string `json:"accountId,omitempty"` + RegionId *string `json:"regionId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_appserviceinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_appserviceinfo.go new file mode 100644 index 000000000000..871a36881b64 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_appserviceinfo.go @@ -0,0 +1,16 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceInfo struct { + AutoUpdateSetting *AutoUpdateSetting `json:"autoUpdateSetting,omitempty"` + AvailabilityState *AvailabilityState `json:"availabilityState,omitempty"` + HostGroup *string `json:"hostGroup,omitempty"` + HostName *string `json:"hostName,omitempty"` + LogModule *LogModule `json:"logModule,omitempty"` + MonitoringType *MonitoringType `json:"monitoringType,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + UpdateStatus *UpdateStatus `json:"updateStatus,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatraceenvironmentproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatraceenvironmentproperties.go new file mode 100644 index 000000000000..1fea77b2533f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatraceenvironmentproperties.go @@ -0,0 +1,11 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DynatraceEnvironmentProperties struct { + AccountInfo *AccountInfo `json:"accountInfo,omitempty"` + EnvironmentInfo *EnvironmentInfo `json:"environmentInfo,omitempty"` + SingleSignOnProperties *DynatraceSingleSignOnProperties `json:"singleSignOnProperties,omitempty"` + UserId *string `json:"userId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatracesinglesignonproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatracesinglesignonproperties.go new file mode 100644 index 000000000000..e4127bd73179 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_dynatracesinglesignonproperties.go @@ -0,0 +1,12 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DynatraceSingleSignOnProperties struct { + AadDomains *[]string `json:"aadDomains,omitempty"` + EnterpriseAppId *string `json:"enterpriseAppId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SingleSignOnState *SingleSignOnStates `json:"singleSignOnState,omitempty"` + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_environmentinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_environmentinfo.go new file mode 100644 index 000000000000..84092e2b7a8c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_environmentinfo.go @@ -0,0 +1,11 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentInfo struct { + EnvironmentId *string `json:"environmentId,omitempty"` + IngestionKey *string `json:"ingestionKey,omitempty"` + LandingURL *string `json:"landingURL,omitempty"` + LogsIngestionEndpoint *string `json:"logsIngestionEndpoint,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_identityproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_identityproperties.go new file mode 100644 index 000000000000..4d07c3343973 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_identityproperties.go @@ -0,0 +1,11 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProperties struct { + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type ManagedIdentityType `json:"type"` + UserAssignedIdentities *map[string]UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentrequest.go new file mode 100644 index 000000000000..c6c728c183e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentrequest.go @@ -0,0 +1,10 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkableEnvironmentRequest struct { + Region string `json:"region"` + TenantId string `json:"tenantId"` + UserPrincipal string `json:"userPrincipal"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentresponse.go new file mode 100644 index 000000000000..aa1d21d9ce07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_linkableenvironmentresponse.go @@ -0,0 +1,10 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkableEnvironmentResponse struct { + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentName *string `json:"environmentName,omitempty"` + PlanData *PlanData `json:"planData,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsrequest.go new file mode 100644 index 000000000000..2abdb1801f49 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsrequest.go @@ -0,0 +1,8 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceSaaSResourceDetailsRequest struct { + TenantId string `json:"tenantId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsresponse.go new file mode 100644 index 000000000000..42b8b31dafa0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_marketplacesaasresourcedetailsresponse.go @@ -0,0 +1,10 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceSaaSResourceDetailsResponse struct { + MarketplaceSaaSResourceId *string `json:"marketplaceSaaSResourceId,omitempty"` + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + PlanId *string `json:"planId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_metricsstatusresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_metricsstatusresponse.go new file mode 100644 index 000000000000..d04cdbc51626 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_metricsstatusresponse.go @@ -0,0 +1,8 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricsStatusResponse struct { + AzureResourceIds *[]string `json:"azureResourceIds,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitoredresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitoredresource.go new file mode 100644 index 000000000000..5c2b3a677e26 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitoredresource.go @@ -0,0 +1,12 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoredResource struct { + Id *string `json:"id,omitempty"` + ReasonForLogsStatus *string `json:"reasonForLogsStatus,omitempty"` + ReasonForMetricsStatus *string `json:"reasonForMetricsStatus,omitempty"` + SendingLogs *SendingLogsStatus `json:"sendingLogs,omitempty"` + SendingMetrics *SendingMetricsStatus `json:"sendingMetrics,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorproperties.go new file mode 100644 index 000000000000..aea9c3bac03f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorproperties.go @@ -0,0 +1,15 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitorProperties struct { + DynatraceEnvironmentProperties *DynatraceEnvironmentProperties `json:"dynatraceEnvironmentProperties,omitempty"` + LiftrResourceCategory *LiftrResourceCategories `json:"liftrResourceCategory,omitempty"` + LiftrResourcePreference *int64 `json:"liftrResourcePreference,omitempty"` + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` + PlanData *PlanData `json:"planData,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UserInfo *UserInfo `json:"userInfo,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresource.go new file mode 100644 index 000000000000..41a59fc156c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresource.go @@ -0,0 +1,19 @@ +package monitors + +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 MonitorResource struct { + Id *string `json:"id,omitempty"` + Identity *IdentityProperties `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties MonitorProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresourceupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresourceupdate.go new file mode 100644 index 000000000000..e4b9650dd5ba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_monitorresourceupdate.go @@ -0,0 +1,8 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitorResourceUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_plandata.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_plandata.go new file mode 100644 index 000000000000..00c8e7373ed2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_plandata.go @@ -0,0 +1,29 @@ +package monitors + +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 PlanData struct { + BillingCycle *string `json:"billingCycle,omitempty"` + EffectiveDate *string `json:"effectiveDate,omitempty"` + PlanDetails *string `json:"planDetails,omitempty"` + UsageType *string `json:"usageType,omitempty"` +} + +func (o *PlanData) GetEffectiveDateAsTime() (*time.Time, error) { + if o.EffectiveDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EffectiveDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *PlanData) SetEffectiveDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EffectiveDate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsrequest.go new file mode 100644 index 000000000000..13edd253ec65 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsrequest.go @@ -0,0 +1,8 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SSODetailsRequest struct { + UserPrincipal string `json:"userPrincipal"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsresponse.go new file mode 100644 index 000000000000..e25604ac82f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_ssodetailsresponse.go @@ -0,0 +1,12 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SSODetailsResponse struct { + AadDomains *[]string `json:"aadDomains,omitempty"` + AdminUsers *[]string `json:"adminUsers,omitempty"` + IsSsoEnabled *SSOStatus `json:"isSsoEnabled,omitempty"` + MetadataURL *string `json:"metadataUrl,omitempty"` + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userassignedidentity.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userassignedidentity.go new file mode 100644 index 000000000000..e0be88201f27 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userassignedidentity.go @@ -0,0 +1,9 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentity struct { + ClientId string `json:"clientId"` + PrincipalId string `json:"principalId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userinfo.go new file mode 100644 index 000000000000..f46f2830381f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_userinfo.go @@ -0,0 +1,12 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserInfo struct { + Country *string `json:"country,omitempty"` + EmailAddress *string `json:"emailAddress,omitempty"` + FirstName *string `json:"firstName,omitempty"` + LastName *string `json:"lastName,omitempty"` + PhoneNumber *string `json:"phoneNumber,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vmextensionpayload.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vmextensionpayload.go new file mode 100644 index 000000000000..c3ed74aee1a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vmextensionpayload.go @@ -0,0 +1,9 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMExtensionPayload struct { + EnvironmentId *string `json:"environmentId,omitempty"` + IngestionKey *string `json:"ingestionKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vminfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vminfo.go new file mode 100644 index 000000000000..02fe3b6e73b4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/model_vminfo.go @@ -0,0 +1,16 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMInfo struct { + AutoUpdateSetting *AutoUpdateSetting `json:"autoUpdateSetting,omitempty"` + AvailabilityState *AvailabilityState `json:"availabilityState,omitempty"` + HostGroup *string `json:"hostGroup,omitempty"` + HostName *string `json:"hostName,omitempty"` + LogModule *LogModule `json:"logModule,omitempty"` + MonitoringType *MonitoringType `json:"monitoringType,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + UpdateStatus *UpdateStatus `json:"updateStatus,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/predicates.go new file mode 100644 index 000000000000..0f71e7af6b19 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/predicates.go @@ -0,0 +1,129 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceInfoOperationPredicate struct { + HostGroup *string + HostName *string + ResourceId *string + Version *string +} + +func (p AppServiceInfoOperationPredicate) Matches(input AppServiceInfo) bool { + + if p.HostGroup != nil && (input.HostGroup == nil || *p.HostGroup != *input.HostGroup) { + return false + } + + if p.HostName != nil && (input.HostName == nil || *p.HostName != *input.HostName) { + return false + } + + if p.ResourceId != nil && (input.ResourceId == nil || *p.ResourceId != *input.ResourceId) { + return false + } + + if p.Version != nil && (input.Version == nil || *p.Version != *input.Version) { + return false + } + + return true +} + +type LinkableEnvironmentResponseOperationPredicate struct { + EnvironmentId *string + EnvironmentName *string +} + +func (p LinkableEnvironmentResponseOperationPredicate) Matches(input LinkableEnvironmentResponse) bool { + + if p.EnvironmentId != nil && (input.EnvironmentId == nil || *p.EnvironmentId != *input.EnvironmentId) { + return false + } + + if p.EnvironmentName != nil && (input.EnvironmentName == nil || *p.EnvironmentName != *input.EnvironmentName) { + return false + } + + return true +} + +type MonitorResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MonitorResourceOperationPredicate) Matches(input MonitorResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type MonitoredResourceOperationPredicate struct { + Id *string + ReasonForLogsStatus *string + ReasonForMetricsStatus *string +} + +func (p MonitoredResourceOperationPredicate) Matches(input MonitoredResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.ReasonForLogsStatus != nil && (input.ReasonForLogsStatus == nil || *p.ReasonForLogsStatus != *input.ReasonForLogsStatus) { + return false + } + + if p.ReasonForMetricsStatus != nil && (input.ReasonForMetricsStatus == nil || *p.ReasonForMetricsStatus != *input.ReasonForMetricsStatus) { + return false + } + + return true +} + +type VMInfoOperationPredicate struct { + HostGroup *string + HostName *string + ResourceId *string + Version *string +} + +func (p VMInfoOperationPredicate) Matches(input VMInfo) bool { + + if p.HostGroup != nil && (input.HostGroup == nil || *p.HostGroup != *input.HostGroup) { + return false + } + + if p.HostName != nil && (input.HostName == nil || *p.HostName != *input.HostName) { + return false + } + + if p.ResourceId != nil && (input.ResourceId == nil || *p.ResourceId != *input.ResourceId) { + return false + } + + if p.Version != nil && (input.Version == nil || *p.Version != *input.Version) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/version.go new file mode 100644 index 000000000000..003df71b2e49 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors/version.go @@ -0,0 +1,10 @@ +package monitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-04-27" + +func userAgent() string { + return "hashicorp/go-azure-sdk/monitors/2023-04-27" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d2e5d1340bcc..71aeb72b62fb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -499,6 +499,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/dnsresolver/2022-07-01/forwar github.com/hashicorp/go-azure-sdk/resource-manager/dnsresolver/2022-07-01/inboundendpoints github.com/hashicorp/go-azure-sdk/resource-manager/dnsresolver/2022-07-01/outboundendpoints github.com/hashicorp/go-azure-sdk/resource-manager/dnsresolver/2022-07-01/virtualnetworklinks +github.com/hashicorp/go-azure-sdk/resource-manager/dynatrace/2023-04-27/monitors github.com/hashicorp/go-azure-sdk/resource-manager/elastic/2023-06-01/monitorsresource github.com/hashicorp/go-azure-sdk/resource-manager/elastic/2023-06-01/rules github.com/hashicorp/go-azure-sdk/resource-manager/elasticsan/2023-01-01 diff --git a/website/allowed-subcategories b/website/allowed-subcategories index b724cc6c40bb..fa46a484f3dc 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -48,6 +48,7 @@ Desktop Virtualization Dev Center Dev Test Digital Twins +Dynatrace Elastic Elastic SAN Extended Location diff --git a/website/docs/r/dynatrace_monitors.html.markdown b/website/docs/r/dynatrace_monitors.html.markdown new file mode 100644 index 000000000000..2718e910137b --- /dev/null +++ b/website/docs/r/dynatrace_monitors.html.markdown @@ -0,0 +1,125 @@ +--- +subcategory: "Dynatrace" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_dynatrace_monitor" +description: |- + Manages Dynatrace monitors. +--- + +# azurerm_dynatrace_monitors + +Manages Dynatrace monitors. + +## Example Usage + +```hcl + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_dynatrace_monitor" "example" { + name = "exmpledynatracemonitor" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.test.location + monitoring_enabled = true + marketplace_subscription_status = "Active" + + identity { + type = "SystemAssigned" + } + + user { + first_name = "Alice" + last_name = "Bobab" + email = "alice@microsoft.com" + phone_number = "123456" + country = "westus" + } + + plan { + usage_type = "COMMITTED" + billing_cycle = "MONTHLY" + plan = "azureportalintegration_privatepreview@TIDhjdtn7tfnxcy" + effective_date = "2019-08-30T15:14:33Z" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Name of the Dynatrace monitor. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Dynatrace monitor should exist. Changing this forces a new resource to be created. + +* `location` - (Required) The Azure Region where the Dynatrace monitor should exist. Changing this forces a new resource to be created. + +* `identity` - (Required) The kind of managed identity assigned to this resource. A `identity` block as defined below. + +* `marketplace_subscription` - (Required) Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state. Possible values are `Active` and `Suspended`. + +* `plan` - (Required) Billing plan information. A `plan` block as defined below. Changing this forces a new resource to be created. + +* `user` - (Required) User's information. A `user` block as defined below. Chainging this forces a new resource to be created. + +* `monitoring_enabled` - (Optional) Flag specifying if the resource monitoring is enabled or disabled. Default is `true`. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +--- + +A `identity` block supports the following: + +* `type` - (Required) The type of identity used for the resource. Only possible value is `SystemAssigned`. + +--- + +A `plan` block supports the following: + +* `billing_cycle` - (Optional) Different billing cycles. Possible values are `MONTHLY` and `WEEKLY`. + +* `effective_date` - (Required) Date when plan was applied. + +* `plan` - (Required) Plan id as published by Dynatrace. + +* `usage_type` - (Optional) Different usage type. Possible values are `PAYG` and `COMMITTED`. + +--- + +A `user` block supports the following: + +* `country` - (Required) Country of the user. + +* `email` - (Required) Email of the user used by Dynatrace for contacting them if needed. + +* `first_name` - (Required) First name of the user. + +* `last_name` - (Required) Last name of the user. + +* `phone_number` - (Required) phone number of the user by Dynatrace for contacting them if needed. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Dynatrace monitor. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 1 hour) Used when creating the Dynatrace monitor. +* `read` - (Defaults to 5 minutes) Used when retrieving the Dynatrace monitor. +* `update` - (Defaults to 1 hour) Used when updating the Dynatrace monitor. +* `delete` - (Defaults to 1 hour) Used when deleting the Dynatrace monitor. + +## Import + +Dynatrace monitor can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_dynatrace_monitor.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Dynatrace.Observability/monitors/monitor1 +```