From 3d00a9fb5810ad3a0e504e864c253b7cb40c50a9 Mon Sep 17 00:00:00 2001 From: catriona-m <86247157+catriona-m@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:35:35 +0100 Subject: [PATCH] `mssql_managed_instance` - upgrade to `2023-08-01-preview` and `hashicorp/go-azure-sdk` (#26872) * upgrade managed instance * fix ids * add storage consts, fix id errs * fix id in delete * delete aad first * fix id * increase delete timeout * increase delete timeout * rebase * fix linting issue - gocritic nil check * test fixes * more test fixes * remove manual route config as table is managed by service now --------- Co-authored-by: jackofallops --- internal/clients/client.go | 4 +- .../mssqlmanagedinstance/client/client.go | 138 ++- .../mssql_managed_database_resource.go | 167 ++- .../mssql_managed_database_resource_test.go | 23 +- ...active_directory_administrator_resource.go | 151 +-- ...e_directory_administrator_resource_test.go | 8 +- .../mssql_managed_instance_data_source.go | 107 +- ...anaged_instance_failover_group_resource.go | 172 ++- ...d_instance_failover_group_resource_test.go | 9 +- .../mssql_managed_instance_resource.go | 311 +++-- .../mssql_managed_instance_resource_test.go | 1085 ++--------------- ...instance_security_alert_policy_resource.go | 175 +-- ...nce_security_alert_policy_resource_test.go | 10 +- ...ce_transparent_data_encryption_resource.go | 112 +- ...ansparent_data_encryption_resource_test.go | 11 +- ...tance_vulnerability_assessment_resource.go | 58 +- ..._vulnerability_assessment_resource_test.go | 10 +- .../instancefailovergroups/README.md | 106 ++ .../instancefailovergroups/client.go | 26 + .../instancefailovergroups/constants.go | 174 +++ .../id_instancefailovergroup.go | 139 +++ .../id_providerlocation.go | 130 ++ .../method_createorupdate.go | 76 ++ .../instancefailovergroups/method_delete.go | 71 ++ .../instancefailovergroups/method_failover.go | 71 ++ .../method_forcefailoverallowdataloss.go | 71 ++ .../instancefailovergroups/method_get.go | 54 + .../method_listbylocation.go | 105 ++ .../model_instancefailovergroup.go | 11 + .../model_instancefailovergroupproperties.go | 14 + ...l_instancefailovergroupreadonlyendpoint.go | 8 + ..._instancefailovergroupreadwriteendpoint.go | 9 + .../model_managedinstancepairinfo.go | 9 + .../model_partnerregioninfo.go | 9 + .../instancefailovergroups/predicates.go | 27 + .../instancefailovergroups/version.go | 12 + .../README.md | 88 ++ .../client.go | 26 + .../method_createorupdate.go | 76 ++ .../method_get.go | 56 + .../method_listbydatabase.go | 106 ++ .../method_update.go | 76 ++ ...l_managedbackupshorttermretentionpolicy.go | 11 + ...ackupshorttermretentionpolicyproperties.go | 8 + .../predicates.go | 27 + .../version.go | 12 + .../manageddatabases/README.md | 185 +++ .../manageddatabases/client.go | 26 + .../manageddatabases/constants.go | 213 ++++ .../manageddatabases/method_cancelmove.go | 75 ++ .../manageddatabases/method_completemove.go | 75 ++ .../method_completerestore.go | 75 ++ .../manageddatabases/method_createorupdate.go | 77 ++ .../manageddatabases/method_delete.go | 72 ++ .../manageddatabases/method_get.go | 55 + .../manageddatabases/method_listbyinstance.go | 106 ++ .../method_listinaccessiblebyinstance.go | 106 ++ .../manageddatabases/method_startmove.go | 75 ++ .../manageddatabases/method_update.go | 76 ++ ...model_completedatabaserestoredefinition.go | 8 + .../manageddatabases/model_manageddatabase.go | 13 + .../model_manageddatabasemovedefinition.go | 8 + .../model_manageddatabaseproperties.go | 71 ++ ...odel_manageddatabasestartmovedefinition.go | 9 + .../model_manageddatabaseupdate.go | 9 + .../manageddatabases/predicates.go | 32 + .../manageddatabases/version.go | 12 + .../managedinstanceadministrators/README.md | 83 ++ .../managedinstanceadministrators/client.go | 26 + .../constants.go | 48 + .../method_createorupdate.go | 77 ++ .../method_delete.go | 71 ++ .../method_get.go | 56 + .../method_listbyinstance.go | 106 ++ .../model_managedinstanceadministrator.go | 11 + ..._managedinstanceadministratorproperties.go | 11 + .../predicates.go | 27 + .../managedinstanceadministrators/version.go | 12 + .../README.md | 83 ++ .../client.go | 26 + .../method_createorupdate.go | 77 ++ .../method_delete.go | 72 ++ .../method_get.go | 56 + .../method_listbyinstance.go | 106 ++ ...anagedinstanceazureadonlyauthentication.go | 11 + ...anagedinstanceazureadonlyauthproperties.go | 8 + .../predicates.go | 27 + .../version.go | 12 + .../README.md | 83 ++ .../client.go | 26 + .../constants.go | 51 + .../method_createorupdate.go | 76 ++ .../method_get.go | 56 + .../method_listbyinstance.go | 106 ++ .../method_revalidate.go | 71 ++ ...odel_managedinstanceencryptionprotector.go | 12 + ...edinstanceencryptionprotectorproperties.go | 12 + .../predicates.go | 32 + .../version.go | 12 + .../managedinstancekeys/README.md | 83 ++ .../managedinstancekeys/client.go | 26 + .../managedinstancekeys/constants.go | 51 + .../id_managedinstancekey.go | 139 +++ .../method_createorupdate.go | 76 ++ .../managedinstancekeys/method_delete.go | 71 ++ .../managedinstancekeys/method_get.go | 54 + .../method_listbyinstance.go | 134 ++ .../model_managedinstancekey.go | 12 + .../model_managedinstancekeyproperties.go | 30 + .../managedinstancekeys/predicates.go | 32 + .../managedinstancekeys/version.go | 12 + .../README.md | 83 ++ .../client.go | 26 + .../constants.go | 51 + .../method_createorupdate.go | 76 ++ .../method_delete.go | 72 ++ .../method_get.go | 56 + .../method_listbydatabase.go | 106 ++ ..._managedinstancelongtermretentionpolicy.go | 11 + ...stancelongtermretentionpolicyproperties.go | 12 + .../predicates.go | 27 + .../version.go | 12 + .../managedinstances/README.md | 216 ++++ .../managedinstances/client.go | 26 + .../managedinstances/constants.go | 834 +++++++++++++ .../managedinstances/id_instancepool.go | 130 ++ .../managedinstances/method_createorupdate.go | 77 ++ .../managedinstances/method_delete.go | 72 ++ .../managedinstances/method_failover.go | 99 ++ .../managedinstances/method_get.go | 84 ++ .../managedinstances/method_list.go | 134 ++ .../method_listbyinstancepool.go | 133 ++ .../method_listbymanagedinstance.go | 158 +++ .../method_listbyresourcegroup.go | 134 ++ ...undnetworkdependenciesbymanagedinstance.go | 106 ++ .../managedinstances/method_refreshstatus.go | 72 ++ .../managedinstances/method_start.go | 72 ++ .../managedinstances/method_stop.go | 72 ++ .../managedinstances/method_update.go | 76 ++ .../model_endpointdependency.go | 9 + .../managedinstances/model_endpointdetail.go | 8 + .../managedinstances/model_managedinstance.go | 19 + ...el_managedinstanceexternaladministrator.go | 13 + .../model_managedinstancepecproperty.go | 9 + ...anceprivateendpointconnectionproperties.go | 10 + ..._managedinstanceprivateendpointproperty.go | 8 + ...ivatelinkserviceconnectionstateproperty.go | 10 + .../model_managedinstanceproperties.go | 78 ++ .../model_managedinstanceupdate.go | 15 + .../model_outboundenvironmentendpoint.go | 9 + .../model_querymetricinterval.go | 11 + .../model_querymetricproperties.go | 16 + .../model_querystatisticsproperties.go | 12 + ...ternalgovernancestatusoperationresultmi.go | 11 + ...rnancestatusoperationresultpropertiesmi.go | 13 + .../model_serviceprincipal.go | 11 + .../managedinstances/model_sku.go | 12 + .../managedinstances/model_topqueries.go | 14 + .../managedinstances/predicates.go | 78 ++ .../managedinstances/version.go | 12 + .../README.md | 91 ++ .../client.go | 26 + .../method_createorupdate.go | 61 + .../method_delete.go | 48 + .../method_get.go | 56 + .../method_listbyinstance.go | 106 ++ ..._managedinstancevulnerabilityassessment.go | 11 + ...stancevulnerabilityassessmentproperties.go | 11 + ...ilityassessmentrecurringscansproperties.go | 10 + .../predicates.go | 27 + .../version.go | 12 + .../README.md | 71 ++ .../client.go | 26 + .../constants.go | 51 + .../method_createorupdate.go | 76 ++ .../method_get.go | 56 + .../method_listbyinstance.go | 106 ++ .../model_managedserversecurityalertpolicy.go | 16 + .../model_securityalertspolicyproperties.go | 33 + .../predicates.go | 27 + .../version.go | 12 + vendor/modules.txt | 11 + ...tive_directory_administrator.html.markdown | 2 +- 183 files changed, 10401 insertions(+), 1750 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_instancefailovergroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_providerlocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_failover.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_forcefailoverallowdataloss.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_listbylocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadonlyendpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadwriteendpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_managedinstancepairinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_partnerregioninfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_listbydatabase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_cancelmove.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completemove.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completerestore.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listinaccessiblebyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_startmove.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_completedatabaserestoredefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasemovedefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasestartmovedefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministrator.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministratorproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthentication.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_revalidate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotector.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotectorproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/id_managedinstancekey.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekey.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekeyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_listbydatabase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/id_instancepool.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_failover.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyinstancepool.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbymanagedinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listoutboundnetworkdependenciesbymanagedinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_refreshstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_start.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_stop.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdependency.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceexternaladministrator.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstancepecproperty.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointconnectionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointproperty.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivatelinkserviceconnectionstateproperty.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_outboundenvironmentendpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricinterval.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querystatisticsproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultmi.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultpropertiesmi.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_serviceprincipal.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_sku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_topqueries.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessment.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessmentproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_vulnerabilityassessmentrecurringscansproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_listbyinstance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_managedserversecurityalertpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_securityalertspolicyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/version.go diff --git a/internal/clients/client.go b/internal/clients/client.go index 5abe26789c57..8b58cd415416 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -541,7 +541,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.MSSQL, err = mssql.NewClient(o); err != nil { return fmt.Errorf("building clients for MSSQL: %+v", err) } - client.MSSQLManagedInstance = mssqlmanagedinstance.NewClient(o) + if client.MSSQLManagedInstance, err = mssqlmanagedinstance.NewClient(o); err != nil { + return fmt.Errorf("building clients for MSSQLManagedInstance: %+v", err) + } if client.MySQL, err = mysql.NewClient(o); err != nil { return fmt.Errorf("building clients for MySQL: %+v", err) } diff --git a/internal/services/mssqlmanagedinstance/client/client.go b/internal/services/mssqlmanagedinstance/client/client.go index f6bb53ff3db4..fd10a31ac330 100644 --- a/internal/services/mssqlmanagedinstance/client/client.go +++ b/internal/services/mssqlmanagedinstance/client/client.go @@ -4,76 +4,122 @@ package client import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - ManagedDatabasesClient *sql.ManagedDatabasesClient - ManagedInstancesClient *sql.ManagedInstancesClient - ManagedInstancesLongTermRetentionPoliciesClient *sql.ManagedInstanceLongTermRetentionPoliciesClient - ManagedInstancesShortTermRetentionPoliciesClient *sql.ManagedBackupShortTermRetentionPoliciesClient - ManagedInstanceVulnerabilityAssessmentsClient *sql.ManagedInstanceVulnerabilityAssessmentsClient - ManagedInstanceServerSecurityAlertPoliciesClient *sql.ManagedServerSecurityAlertPoliciesClient - ManagedInstanceAdministratorsClient *sql.ManagedInstanceAdministratorsClient - ManagedInstanceAzureADOnlyAuthenticationsClient *sql.ManagedInstanceAzureADOnlyAuthenticationsClient - ManagedInstanceEncryptionProtectorClient *sql.ManagedInstanceEncryptionProtectorsClient - ManagedInstanceFailoverGroupsClient *sql.InstanceFailoverGroupsClient - ManagedInstanceKeysClient *sql.ManagedInstanceKeysClient + ManagedDatabasesClient *manageddatabases.ManagedDatabasesClient + ManagedInstancesClient *managedinstances.ManagedInstancesClient + ManagedInstancesLongTermRetentionPoliciesClient *managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPoliciesClient + ManagedInstancesShortTermRetentionPoliciesClient *managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPoliciesClient + ManagedInstanceVulnerabilityAssessmentsClient *managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessmentsClient + ManagedInstanceServerSecurityAlertPoliciesClient *managedserversecurityalertpolicies.ManagedServerSecurityAlertPoliciesClient + ManagedInstanceAdministratorsClient *managedinstanceadministrators.ManagedInstanceAdministratorsClient + ManagedInstanceAzureADOnlyAuthenticationsClient *managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthenticationsClient + ManagedInstanceEncryptionProtectorClient *managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtectorsClient + ManagedInstanceFailoverGroupsClient *instancefailovergroups.InstanceFailoverGroupsClient + ManagedInstanceKeysClient *managedinstancekeys.ManagedInstanceKeysClient options *common.ClientOptions } -func NewClient(o *common.ClientOptions) *Client { +func NewClient(o *common.ClientOptions) (*Client, error) { - managedDatabasesClient := sql.NewManagedDatabasesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedDatabasesClient.Client, o.ResourceManagerAuthorizer) + managedDatabasesClient, err := manageddatabases.NewManagedDatabasesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Databases Client: %+v", err) + } + o.Configure(managedDatabasesClient.Client, o.Authorizers.ResourceManager) - managedInstancesClient := sql.NewManagedInstancesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstancesClient.Client, o.ResourceManagerAuthorizer) + managedInstancesClient, err := managedinstances.NewManagedInstancesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Client: %+v", err) + } + o.Configure(managedInstancesClient.Client, o.Authorizers.ResourceManager) - managedInstancesLongTermRetentionPoliciesClient := sql.NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstancesLongTermRetentionPoliciesClient.Client, o.ResourceManagerAuthorizer) + managedInstancesLongTermRetentionPoliciesClient, err := managedinstancelongtermretentionpolicies.NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Long Term Retention Policies Client: %+v", err) + } + o.Configure(managedInstancesLongTermRetentionPoliciesClient.Client, o.Authorizers.ResourceManager) - managedInstancesShortTermRetentionPoliciesClient := sql.NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstancesShortTermRetentionPoliciesClient.Client, o.ResourceManagerAuthorizer) + managedInstancesShortTermRetentionPoliciesClient, err := managedbackupshorttermretentionpolicies.NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Short Term Retention Policies Client: %+v", err) + } + o.Configure(managedInstancesShortTermRetentionPoliciesClient.Client, o.Authorizers.ResourceManager) - managedInstancesAdministratorsClient := sql.NewManagedInstanceAdministratorsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstancesAdministratorsClient.Client, o.ResourceManagerAuthorizer) + managedInstancesAdministratorsClient, err := managedinstanceadministrators.NewManagedInstanceAdministratorsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Administrators Client: %+v", err) + } + o.Configure(managedInstancesAdministratorsClient.Client, o.Authorizers.ResourceManager) - managedInstanceAzureADOnlyAuthenticationsClient := sql.NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceAzureADOnlyAuthenticationsClient.Client, o.ResourceManagerAuthorizer) + managedInstanceAzureADOnlyAuthenticationsClient, err := managedinstanceazureadonlyauthentications.NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Azure ADOnly Authentications Client: %+v", err) + } + o.Configure(managedInstanceAzureADOnlyAuthenticationsClient.Client, o.Authorizers.ResourceManager) - managedInstanceEncryptionProtectorsClient := sql.NewManagedInstanceEncryptionProtectorsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceEncryptionProtectorsClient.Client, o.ResourceManagerAuthorizer) + managedInstanceEncryptionProtectorsClient, err := managedinstanceencryptionprotectors.NewManagedInstanceEncryptionProtectorsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Encryption Protectors Client: %+v", err) + } + o.Configure(managedInstanceEncryptionProtectorsClient.Client, o.Authorizers.ResourceManager) - managedInstanceFailoverGroupsClient := sql.NewInstanceFailoverGroupsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceFailoverGroupsClient.Client, o.ResourceManagerAuthorizer) + managedInstanceFailoverGroupsClient, err := instancefailovergroups.NewInstanceFailoverGroupsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Failover Groups Client: %+v", err) + } + o.Configure(managedInstanceFailoverGroupsClient.Client, o.Authorizers.ResourceManager) - managedInstanceKeysClient := sql.NewManagedInstanceKeysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceKeysClient.Client, o.ResourceManagerAuthorizer) + managedInstanceKeysClient, err := managedinstancekeys.NewManagedInstanceKeysClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Keys Client: %+v", err) + } + o.Configure(managedInstanceKeysClient.Client, o.Authorizers.ResourceManager) - managedInstanceVulnerabilityAssessmentsClient := sql.NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceVulnerabilityAssessmentsClient.Client, o.ResourceManagerAuthorizer) + managedInstanceVulnerabilityAssessmentsClient, err := managedinstancevulnerabilityassessments.NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Vulnerability Assessments Client: %+v", err) + } + o.Configure(managedInstanceVulnerabilityAssessmentsClient.Client, o.Authorizers.ResourceManager) - managedInstanceServerSecurityAlertPoliciesClient := sql.NewManagedServerSecurityAlertPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&managedInstanceServerSecurityAlertPoliciesClient.Client, o.ResourceManagerAuthorizer) + managedInstanceServerSecurityAlertPoliciesClient, err := managedserversecurityalertpolicies.NewManagedServerSecurityAlertPoliciesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Managed Instance Server Security Alert Policies Client: %+v", err) + } + o.Configure(managedInstanceServerSecurityAlertPoliciesClient.Client, o.Authorizers.ResourceManager) return &Client{ - ManagedDatabasesClient: &managedDatabasesClient, - ManagedInstanceAdministratorsClient: &managedInstancesAdministratorsClient, - ManagedInstanceAzureADOnlyAuthenticationsClient: &managedInstanceAzureADOnlyAuthenticationsClient, - ManagedInstanceEncryptionProtectorClient: &managedInstanceEncryptionProtectorsClient, - ManagedInstanceFailoverGroupsClient: &managedInstanceFailoverGroupsClient, - ManagedInstanceKeysClient: &managedInstanceKeysClient, - ManagedInstancesLongTermRetentionPoliciesClient: &managedInstancesLongTermRetentionPoliciesClient, - ManagedInstanceServerSecurityAlertPoliciesClient: &managedInstanceServerSecurityAlertPoliciesClient, - ManagedInstancesShortTermRetentionPoliciesClient: &managedInstancesShortTermRetentionPoliciesClient, - ManagedInstanceVulnerabilityAssessmentsClient: &managedInstanceVulnerabilityAssessmentsClient, - ManagedInstancesClient: &managedInstancesClient, + ManagedDatabasesClient: managedDatabasesClient, + ManagedInstanceAdministratorsClient: managedInstancesAdministratorsClient, + ManagedInstanceAzureADOnlyAuthenticationsClient: managedInstanceAzureADOnlyAuthenticationsClient, + ManagedInstanceEncryptionProtectorClient: managedInstanceEncryptionProtectorsClient, + ManagedInstanceFailoverGroupsClient: managedInstanceFailoverGroupsClient, + ManagedInstanceKeysClient: managedInstanceKeysClient, + ManagedInstancesLongTermRetentionPoliciesClient: managedInstancesLongTermRetentionPoliciesClient, + ManagedInstanceServerSecurityAlertPoliciesClient: managedInstanceServerSecurityAlertPoliciesClient, + ManagedInstancesShortTermRetentionPoliciesClient: managedInstancesShortTermRetentionPoliciesClient, + ManagedInstanceVulnerabilityAssessmentsClient: managedInstanceVulnerabilityAssessmentsClient, + ManagedInstancesClient: managedInstancesClient, options: o, - } + }, nil } func (c Client) ManagedInstancesClientForSubscription(subscriptionID string) *sql.ManagedInstancesClient { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_database_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_database_resource.go index d7024945e638..6803b6fdc4b8 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_database_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_database_resource.go @@ -8,19 +8,21 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck - "github.com/Azure/go-autorest/autorest/date" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/helper" miParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/sql/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type MsSqlManagedDatabaseModel struct { @@ -129,86 +131,75 @@ func (r MsSqlManagedDatabaseResource) Create() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - managedInstanceId, err := parse.ManagedInstanceID(model.ManagedInstanceId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(model.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `managed_instance_id`: %v", err) + return err } - id := parse.NewManagedDatabaseID(managedInstanceId.SubscriptionId, - managedInstanceId.ResourceGroup, managedInstanceId.Name, model.Name) + id := commonids.NewSqlManagedInstanceDatabaseID(managedInstanceId.SubscriptionId, + managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, model.Name) - managedInstance, err := instancesClient.Get(ctx, managedInstanceId.ResourceGroup, managedInstanceId.Name, "") - if err != nil || managedInstance.Location == nil || *managedInstance.Location == "" { + managedInstance, err := instancesClient.Get(ctx, *managedInstanceId, managedinstances.GetOperationOptions{}) + if err != nil || managedInstance.Model == nil || managedInstance.Model.Location == "" { return fmt.Errorf("checking for existence and region of Managed Instance for %s: %+v", id, err) } metadata.Logger.Infof("Import check for %s", id) - existing, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) - if err != nil && !utils.ResponseWasNotFound(existing.Response) { + 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 !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - parameters := sql.ManagedDatabase{ - Location: managedInstance.Location, - ManagedDatabaseProperties: &sql.ManagedDatabaseProperties{}, + parameters := manageddatabases.ManagedDatabase{ + Location: managedInstance.Model.Location, + Properties: &manageddatabases.ManagedDatabaseProperties{}, } if len(model.PointInTimeRestore) > 0 { restorePointInTime := model.PointInTimeRestore[0] - parameters.CreateMode = sql.ManagedDatabaseCreateModePointInTimeRestore - t, _ := time.Parse(time.RFC3339, restorePointInTime.RestorePointInTime) - parameters.RestorePointInTime = &date.Time{ - Time: t, - } + parameters.Properties.CreateMode = pointer.To(manageddatabases.ManagedDatabaseCreateModePointInTimeRestore) + parameters.Properties.RestorePointInTime = &restorePointInTime.RestorePointInTime _, err := miParse.RestorableDroppedDatabaseID(restorePointInTime.SourceDatabaseId) if err == nil { - parameters.RestorableDroppedDatabaseID = pointer.To(restorePointInTime.SourceDatabaseId) + parameters.Properties.RestorableDroppedDatabaseId = pointer.To(restorePointInTime.SourceDatabaseId) } else { - parameters.SourceDatabaseID = pointer.To(restorePointInTime.SourceDatabaseId) + parameters.Properties.SourceDatabaseId = pointer.To(restorePointInTime.SourceDatabaseId) } } metadata.Logger.Infof("Creating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName, parameters) + err = client.CreateOrUpdateThenPoll(ctx, id, parameters) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - if len(model.LongTermRetentionPolicy) > 0 { longTermRetentionProps := expandLongTermRetentionPolicy(model.LongTermRetentionPolicy) - longTermRetentionPolicy := sql.ManagedInstanceLongTermRetentionPolicy{ - BaseLongTermRetentionPolicyProperties: &longTermRetentionProps, + longTermRetentionPolicy := managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicy{ + Properties: &longTermRetentionProps, } - longTermRetentionFuture, err := longTermRetentionClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName, longTermRetentionPolicy) + err := longTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, longTermRetentionPolicy) if err != nil { return fmt.Errorf("setting Long Term Retention Policies for %s: %+v", id, err) } - - if err = longTermRetentionFuture.WaitForCompletionRef(ctx, longTermRetentionClient.Client); err != nil { - return fmt.Errorf("waiting for update of Long Term Retention Policies for %s: %+v", id, err) - } } if model.ShortTermRetentionDays > 0 { - shortTermRetentionPolicy := sql.ManagedBackupShortTermRetentionPolicy{ - ManagedBackupShortTermRetentionPolicyProperties: &sql.ManagedBackupShortTermRetentionPolicyProperties{ - RetentionDays: pointer.To(int32(model.ShortTermRetentionDays)), + shortTermRetentionPolicy := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{ + Properties: &managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicyProperties{ + RetentionDays: pointer.To(model.ShortTermRetentionDays), }, } - if _, err := shortTermRetentionClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName, shortTermRetentionPolicy); err != nil { + if err = shortTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, shortTermRetentionPolicy); err != nil { return fmt.Errorf("setting Short Term Retention Policy for %s: %+v", id, err) } } @@ -232,41 +223,37 @@ func (r MsSqlManagedDatabaseResource) Update() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - managedInstanceId, err := parse.ManagedInstanceID(model.ManagedInstanceId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(model.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `managed_instance_id`: %v", err) + return err } - id := parse.NewManagedDatabaseID(managedInstanceId.SubscriptionId, - managedInstanceId.ResourceGroup, managedInstanceId.Name, model.Name) + id := commonids.NewSqlManagedInstanceDatabaseID(managedInstanceId.SubscriptionId, + managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, model.Name) d := metadata.ResourceData if d.HasChange("long_term_retention_policy") { longTermRetentionProps := expandLongTermRetentionPolicy(model.LongTermRetentionPolicy) - longTermRetentionPolicy := sql.ManagedInstanceLongTermRetentionPolicy{ - BaseLongTermRetentionPolicyProperties: &longTermRetentionProps, + longTermRetentionPolicy := managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicy{ + Properties: &longTermRetentionProps, } - longTermRetentionFuture, err := longTermRetentionClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName, longTermRetentionPolicy) + err := longTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, longTermRetentionPolicy) if err != nil { return fmt.Errorf("updating Long Term Retention Policies for %s: %+v", id, err) } - - if err = longTermRetentionFuture.WaitForCompletionRef(ctx, longTermRetentionClient.Client); err != nil { - return fmt.Errorf("waiting for update of Long Term Retention Policies for %s: %+v", id, err) - } } if d.HasChange("short_term_retention_days") { - shortTermRetentionPolicy := sql.ManagedBackupShortTermRetentionPolicy{ - ManagedBackupShortTermRetentionPolicyProperties: &sql.ManagedBackupShortTermRetentionPolicyProperties{ - RetentionDays: pointer.To(int32(model.ShortTermRetentionDays)), + shortTermRetentionPolicy := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{ + Properties: &managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicyProperties{ + RetentionDays: pointer.To(model.ShortTermRetentionDays), }, } - if _, err := shortTermRetentionClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName, shortTermRetentionPolicy); err != nil { + if err = shortTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, shortTermRetentionPolicy); err != nil { return fmt.Errorf("updating Short Term Retention Policy for %s: %+v", id, err) } } @@ -283,7 +270,7 @@ func (r MsSqlManagedDatabaseResource) Read() sdk.ResourceFunc { longTermRetentionClient := metadata.Client.MSSQLManagedInstance.ManagedInstancesLongTermRetentionPoliciesClient shortTermRetentionClient := metadata.Client.MSSQLManagedInstance.ManagedInstancesShortTermRetentionPoliciesClient - id, err := parse.ManagedDatabaseID(metadata.ResourceData.Id()) + id, err := commonids.ParseManagedInstanceDatabaseID(metadata.ResourceData.Id()) if err != nil { return err } @@ -294,35 +281,37 @@ func (r MsSqlManagedDatabaseResource) Read() sdk.ResourceFunc { return err } - result, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) + result, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(result.Response) { + if response.WasNotFound(result.HttpResponse) { return metadata.MarkAsGone(id) } return fmt.Errorf("retrieving %s: %v", *id, err) } - managedInstanceId := parse.NewManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroupName, id.ManagedInstanceName) model := MsSqlManagedDatabaseModel{ Name: id.DatabaseName, ManagedInstanceId: managedInstanceId.ID(), } - ltrResp, err := longTermRetentionClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) + ltrResp, err := longTermRetentionClient.Get(ctx, *id) if err != nil { return fmt.Errorf("retrieving Long Term Retention Policy for %s: %v", *id, err) } - model.LongTermRetentionPolicy = flattenLongTermRetentionPolicy(ltrResp) + if ltrResp.Model != nil && ltrResp.Model.Properties != nil { + model.LongTermRetentionPolicy = flattenLongTermRetentionPolicy(*ltrResp.Model.Properties) + } - shortTermRetentionResp, err := shortTermRetentionClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) + shortTermRetentionResp, err := shortTermRetentionClient.Get(ctx, *id) if err != nil { return fmt.Errorf("retrieving Short Term Retention Policy for %s: %v", *id, err) } - if shortTermRetentionResp.RetentionDays != nil { - model.ShortTermRetentionDays = int64(*shortTermRetentionResp.RetentionDays) + if shortTermRetentionResp.Model != nil && shortTermRetentionResp.Model.Properties != nil { + model.ShortTermRetentionDays = pointer.From(shortTermRetentionResp.Model.Properties.RetentionDays) } d := metadata.ResourceData @@ -341,18 +330,14 @@ func (r MsSqlManagedDatabaseResource) Delete() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedDatabasesClient - id, err := parse.ManagedDatabaseID(metadata.ResourceData.Id()) + id, err := commonids.ParseManagedInstanceDatabaseID(metadata.ResourceData.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) + err = client.DeleteThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", id, err) + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil @@ -360,42 +345,26 @@ func (r MsSqlManagedDatabaseResource) Delete() sdk.ResourceFunc { } } -func expandLongTermRetentionPolicy(ltrPolicy []LongTermRetentionPolicy) sql.BaseLongTermRetentionPolicyProperties { - return sql.BaseLongTermRetentionPolicyProperties{ +func expandLongTermRetentionPolicy(ltrPolicy []LongTermRetentionPolicy) managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicyProperties { + if len(ltrPolicy) == 0 { + return managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicyProperties{} + } + + return managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicyProperties{ WeeklyRetention: <rPolicy[0].WeeklyRetention, MonthlyRetention: <rPolicy[0].MonthlyRetention, YearlyRetention: <rPolicy[0].YearlyRetention, - WeekOfYear: pointer.To(int32(ltrPolicy[0].WeekOfYear)), + WeekOfYear: pointer.To(ltrPolicy[0].WeekOfYear), } } -func flattenLongTermRetentionPolicy(ltrPolicy sql.ManagedInstanceLongTermRetentionPolicy) []LongTermRetentionPolicy { - - ltrModel := LongTermRetentionPolicy{} - - weeklyRetention := "" - if ltrPolicy.WeeklyRetention != nil { - weeklyRetention = *ltrPolicy.WeeklyRetention - } - - monthlyRetention := "" - if ltrPolicy.MonthlyRetention != nil { - monthlyRetention = *ltrPolicy.MonthlyRetention - } - - yearlyRetention := "" - if ltrPolicy.YearlyRetention != nil { - yearlyRetention = *ltrPolicy.YearlyRetention - } - - ltrModel = LongTermRetentionPolicy{ - WeeklyRetention: weeklyRetention, - MonthlyRetention: monthlyRetention, - YearlyRetention: yearlyRetention, - } +func flattenLongTermRetentionPolicy(ltrPolicy managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicyProperties) []LongTermRetentionPolicy { - if ltrPolicy.WeekOfYear != nil { - ltrModel.WeekOfYear = int64(*ltrPolicy.WeekOfYear) + ltrModel := LongTermRetentionPolicy{ + WeeklyRetention: pointer.From(ltrPolicy.WeeklyRetention), + MonthlyRetention: pointer.From(ltrPolicy.MonthlyRetention), + YearlyRetention: pointer.From(ltrPolicy.YearlyRetention), + WeekOfYear: pointer.From(ltrPolicy.WeekOfYear), } return []LongTermRetentionPolicy{ltrModel} diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_database_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_database_resource_test.go index 371dd9ac2c82..f2b0739ac601 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_database_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_database_resource_test.go @@ -9,11 +9,12 @@ import ( "testing" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type MsSqlManagedDatabase struct{} @@ -60,14 +61,12 @@ func TestAccMsSqlManagedDatabase_pointInTimeRestore(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), + Config: r.basic(data), // Sets up for pitr }, { PreConfig: func() { time.Sleep(11 * time.Minute) }, - Config: r.pointInTimeRestore(data, time.Now().UTC().Format(time.RFC3339)), + // Valid point in time range from 7 days early to now and not before source server creation time + Config: r.pointInTimeRestore(data, time.Now().Add(-15*time.Minute).UTC().Format(time.RFC3339)), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -77,20 +76,20 @@ func TestAccMsSqlManagedDatabase_pointInTimeRestore(t *testing.T) { } func (r MsSqlManagedDatabase) Exists(ctx context.Context, client *clients.Client, state *acceptance.InstanceState) (*bool, error) { - id, err := parse.ManagedDatabaseID(state.ID) + id, err := commonids.ParseManagedInstanceDatabaseID(state.ID) if err != nil { return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedDatabasesClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName) + resp, err := client.MSSQLManagedInstance.ManagedDatabasesClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return utils.Bool(false), nil + if response.WasNotFound(resp.HttpResponse) { + return pointer.To(false), nil } return nil, fmt.Errorf("retrieving SQL Managed Database %q: %+v", id.ID(), err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (r MsSqlManagedDatabase) basic(data acceptance.TestData) string { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource.go index 749ab807e089..edad0b292045 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource.go @@ -8,15 +8,17 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck - "github.com/gofrs/uuid" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/sql/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type MsSqlManagedInstanceActiveDirectoryAdministratorModel struct { @@ -94,71 +96,53 @@ func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Create() sdk.R return fmt.Errorf("decoding: %+v", err) } - managedInstanceId, err := parse.ManagedInstanceID(model.ManagedInstanceId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(model.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `managed_instance_id`: %v", err) + return err } id := parse.NewManagedInstanceAzureActiveDirectoryAdministratorID(managedInstanceId.SubscriptionId, - managedInstanceId.ResourceGroup, managedInstanceId.Name, string(sql.AdministratorTypeActiveDirectory)) + managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, string(managedinstanceadministrators.ManagedInstanceAdministratorTypeActiveDirectory)) metadata.Logger.Infof("Import check for %s", id) - existing, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) - if err != nil && !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.Get(ctx, *managedInstanceId) + if err != nil && !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - sid, err := uuid.FromString(model.ObjectId) - if err != nil { - return fmt.Errorf("parsing `object_id` for %s", id) - } - - tid, err := uuid.FromString(model.TenantId) - if err != nil { - return fmt.Errorf("parsing `tenant_id` for %s", id) - } - - parameters := sql.ManagedInstanceAdministrator{ - ManagedInstanceAdministratorProperties: &sql.ManagedInstanceAdministratorProperties{ - AdministratorType: utils.String(string(sql.AdministratorTypeActiveDirectory)), - Login: &model.LoginUsername, - Sid: &sid, - TenantID: &tid, + parameters := managedinstanceadministrators.ManagedInstanceAdministrator{ + Properties: &managedinstanceadministrators.ManagedInstanceAdministratorProperties{ + AdministratorType: managedinstanceadministrators.ManagedInstanceAdministratorTypeActiveDirectory, + Login: model.LoginUsername, + Sid: model.ObjectId, + TenantId: &model.TenantId, }, } metadata.Logger.Infof("Creating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, parameters) + err = client.CreateOrUpdateThenPoll(ctx, *managedInstanceId, parameters) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - metadata.SetID(id) - aadAuthOnlyParams := sql.ManagedInstanceAzureADOnlyAuthentication{ - ManagedInstanceAzureADOnlyAuthProperties: &sql.ManagedInstanceAzureADOnlyAuthProperties{ - AzureADOnlyAuthentication: &model.AzureADAuthenticationOnly, + aadAuthOnlyParams := managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthentication{ + Properties: &managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthProperties{ + AzureADOnlyAuthentication: model.AzureADAuthenticationOnly, }, } - aadAuthOnlyFuture, err := aadAuthOnlyClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, aadAuthOnlyParams) + err = aadAuthOnlyClient.CreateOrUpdateThenPoll(ctx, *managedInstanceId, aadAuthOnlyParams) if err != nil { return fmt.Errorf("setting `azuread_authentication_only` for %s: %+v", id, err) } - if err = aadAuthOnlyFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting to set `azuread_authentication_only` for %s: %+v", id, err) - } - return nil }, } @@ -182,51 +166,38 @@ func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Update() sdk.R return err } - sid, err := uuid.FromString(state.ObjectId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(state.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `object_id` for %s", id) - } - - tid, err := uuid.FromString(state.TenantId) - if err != nil { - return fmt.Errorf("parsing `tenant_id` for %s", id) + return err } - properties := sql.ManagedInstanceAdministrator{ - ManagedInstanceAdministratorProperties: &sql.ManagedInstanceAdministratorProperties{ - AdministratorType: utils.String(string(sql.AdministratorTypeActiveDirectory)), - Login: &state.LoginUsername, - Sid: &sid, - TenantID: &tid, + parameters := managedinstanceadministrators.ManagedInstanceAdministrator{ + Properties: &managedinstanceadministrators.ManagedInstanceAdministratorProperties{ + AdministratorType: managedinstanceadministrators.ManagedInstanceAdministratorTypeActiveDirectory, + Login: state.LoginUsername, + Sid: state.ObjectId, + TenantId: &state.TenantId, }, } metadata.Logger.Infof("Updating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, properties) + err = client.CreateOrUpdateThenPoll(ctx, *managedInstanceId, parameters) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", id, err) - } - - aadAuthOnlyProperties := sql.ManagedInstanceAzureADOnlyAuthentication{ - ManagedInstanceAzureADOnlyAuthProperties: &sql.ManagedInstanceAzureADOnlyAuthProperties{ - AzureADOnlyAuthentication: &state.AzureADAuthenticationOnly, + aadAuthOnlyProperties := managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthentication{ + Properties: &managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthProperties{ + AzureADOnlyAuthentication: state.AzureADAuthenticationOnly, }, } - aadAuthOnlyFuture, err := aadAuthOnlyClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, aadAuthOnlyProperties) + err = aadAuthOnlyClient.CreateOrUpdateThenPoll(ctx, *managedInstanceId, aadAuthOnlyProperties) if err != nil { return fmt.Errorf("setting `azuread_authentication_only` for %s: %+v", id, err) } - if err = aadAuthOnlyFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting to set `azuread_authentication_only` for %s: %+v", id, err) - } - return nil }, } @@ -250,40 +221,40 @@ func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Read() sdk.Res return err } - result, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + result, err := client.Get(ctx, managedInstanceId) if err != nil { - if utils.ResponseWasNotFound(result.Response) { + if response.WasNotFound(result.HttpResponse) { return metadata.MarkAsGone(id) } return fmt.Errorf("retrieving %s: %v", id, err) } - instanceId := parse.NewManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) - model := MsSqlManagedInstanceActiveDirectoryAdministratorModel{ - ManagedInstanceId: instanceId.ID(), + ManagedInstanceId: managedInstanceId.ID(), AzureADAuthenticationOnly: false, } - if props := result.ManagedInstanceAdministratorProperties; props != nil { - if props.Login != nil { - model.LoginUsername = *props.Login - } - if props.Sid != nil { - model.ObjectId = props.Sid.String() - } - if props.TenantID != nil { - model.TenantId = props.TenantID.String() + if result.Model != nil { + + if props := result.Model.Properties; props != nil { + model.LoginUsername = props.Login + model.ObjectId = props.Sid + model.TenantId = pointer.From(props.TenantId) + } } - aadAuthOnlyResult, err := aadAuthOnlyClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) - if err != nil && !utils.ResponseWasNotFound(result.Response) { + aadAuthOnlyResult, err := aadAuthOnlyClient.Get(ctx, managedInstanceId) + if err != nil && !response.WasNotFound(result.HttpResponse) { return fmt.Errorf("retrieving `azuread_authentication_only` for %s: %v", id, err) } - if props := aadAuthOnlyResult.ManagedInstanceAzureADOnlyAuthProperties; props != nil && props.AzureADOnlyAuthentication != nil { - model.AzureADAuthenticationOnly = *props.AzureADOnlyAuthentication + if aadAuthOnlyModel := aadAuthOnlyResult.Model; aadAuthOnlyModel != nil { + if props := aadAuthOnlyModel.Properties; props != nil { + model.AzureADAuthenticationOnly = props.AzureADOnlyAuthentication + } } return metadata.Encode(&model) @@ -293,22 +264,26 @@ func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Read() sdk.Res func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, + Timeout: 180 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstanceAdministratorsClient + aadAuthOnlyClient := metadata.Client.MSSQLManagedInstance.ManagedInstanceAzureADOnlyAuthenticationsClient id, err := parse.ManagedInstanceAzureActiveDirectoryAdministratorID(metadata.ResourceData.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + err = aadAuthOnlyClient.DeleteThenPoll(ctx, managedInstanceId) if err != nil { - return fmt.Errorf("deleting %s: %+v", id, err) + return fmt.Errorf("removing `azuread_authentication_only` for %s: %+v", managedInstanceId, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", id, err) + err = client.DeleteThenPoll(ctx, managedInstanceId) + if err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource_test.go index a627070713db..276521cc3ec1 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_active_directory_administrator_resource_test.go @@ -8,6 +8,8 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" @@ -49,9 +51,11 @@ func (r MsSqlManagedInstanceActiveDirectoryAdministratorResource) Exists(ctx con return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstanceAdministratorsClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + resp, err := client.MSSQLManagedInstance.ManagedInstanceAdministratorsClient.Get(ctx, instanceId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving %s: %+v", id, err) diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_data_source.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_data_source.go index 7e5f55338686..23e6de1799f9 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_data_source.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_data_source.go @@ -8,18 +8,17 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/sql/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type MsSqlManagedInstanceDataSourceModel struct { @@ -172,65 +171,51 @@ func (d MsSqlManagedInstanceDataSource) Read() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - id := parse.NewManagedInstanceID(subscriptionId, state.ResourceGroupName, state.Name) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name, "") + id := commonids.NewSqlManagedInstanceID(subscriptionId, state.ResourceGroupName, state.Name) + resp, err := client.Get(ctx, id, managedinstances.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %v", id, err) } + if resp.Model == nil { + return fmt.Errorf("retrieving %s model was nil", id) + } + + if resp.Model.Properties == nil { + return fmt.Errorf("retrieving %s properties was nil", id) + } + model := MsSqlManagedInstanceDataSourceModel{ - Name: id.Name, - Location: location.NormalizeNilable(resp.Location), - ResourceGroupName: id.ResourceGroup, - Identity: d.flattenIdentity(resp.Identity), - Tags: tags.ToTypedObject(resp.Tags), + Name: id.ManagedInstanceName, + Location: resp.Model.Location, + ResourceGroupName: id.ResourceGroupName, + Identity: d.flattenIdentity(resp.Model.Identity), + Tags: pointer.From(resp.Model.Tags), } - if sku := resp.Sku; sku != nil && sku.Name != nil { - model.SkuName = *sku.Name + if sku := resp.Model.Sku; sku != nil { + model.SkuName = sku.Name } - if props := resp.ManagedInstanceProperties; props != nil { - model.LicenseType = string(props.LicenseType) - model.ProxyOverride = string(props.ProxyOverride) - model.StorageAccountType = string(props.StorageAccountType) + if props := resp.Model.Properties; props != nil { + model.LicenseType = string(pointer.From(props.LicenseType)) + model.ProxyOverride = string(pointer.From(props.ProxyOverride)) + model.StorageAccountType = backupStorageRedundancyToStorageAccType(pointer.From(props.RequestedBackupStorageRedundancy)) + model.AdministratorLogin = pointer.From(props.AdministratorLogin) + model.Collation = pointer.From(props.Collation) + model.DnsZone = pointer.From(props.DnsZone) + model.CustomerManagedKeyId = pointer.From(props.KeyId) + model.Fqdn = pointer.From(props.FullyQualifiedDomainName) + model.MinimumTlsVersion = pointer.From(props.MinimalTlsVersion) + model.PublicDataEndpointEnabled = pointer.From(props.PublicDataEndpointEnabled) + model.StorageSizeInGb = pointer.From(props.StorageSizeInGB) + model.SubnetId = pointer.From(props.SubnetId) + model.TimezoneId = pointer.From(props.TimezoneId) + model.VCores = pointer.From(props.VCores) - if props.AdministratorLogin != nil { - model.AdministratorLogin = *props.AdministratorLogin - } - if props.Collation != nil { - model.Collation = *props.Collation - } - if props.DNSZone != nil { - model.DnsZone = *props.DNSZone - } - if props.KeyID != nil { - model.CustomerManagedKeyId = *props.KeyID - } - if props.FullyQualifiedDomainName != nil { - model.Fqdn = *props.FullyQualifiedDomainName - } - if props.MinimalTLSVersion != nil { - model.MinimumTlsVersion = *props.MinimalTLSVersion - } - if props.PublicDataEndpointEnabled != nil { - model.PublicDataEndpointEnabled = *props.PublicDataEndpointEnabled - } - if props.StorageSizeInGB != nil { - model.StorageSizeInGb = int64(*props.StorageSizeInGB) - } - if props.SubnetID != nil { - model.SubnetId = *props.SubnetID - } - if props.TimezoneID != nil { - model.TimezoneId = *props.TimezoneID - } - if props.VCores != nil { - model.VCores = int64(*props.VCores) - } } metadata.SetID(id) @@ -239,23 +224,13 @@ func (d MsSqlManagedInstanceDataSource) Read() sdk.ResourceFunc { } } -func (d MsSqlManagedInstanceDataSource) flattenIdentity(input *sql.ResourceIdentity) []identity.SystemOrUserAssignedList { +func (d MsSqlManagedInstanceDataSource) flattenIdentity(input *identity.LegacySystemAndUserAssignedMap) []identity.SystemOrUserAssignedList { if input == nil { return nil } - principalId := "" - if input.PrincipalID != nil { - principalId = input.PrincipalID.String() - } - - tenantId := "" - if input.TenantID != nil { - tenantId = input.TenantID.String() - } - var identityIds = make([]string, 0) - for k := range input.UserAssignedIdentities { + for k := range input.IdentityIds { parsedId, err := commonids.ParseUserAssignedIdentityIDInsensitively(k) if err != nil { continue @@ -264,9 +239,9 @@ func (d MsSqlManagedInstanceDataSource) flattenIdentity(input *sql.ResourceIdent } return []identity.SystemOrUserAssignedList{{ - Type: identity.Type(input.Type), - PrincipalId: principalId, - TenantId: tenantId, + Type: input.Type, + PrincipalId: input.PrincipalId, + TenantId: input.TenantId, IdentityIds: identityIds, }} } diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource.go index 61e05ae2d4a4..965fcf6109d8 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource.go @@ -8,8 +8,11 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate" @@ -100,8 +103,8 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Arguments() map[string]*plugi Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(sql.ReadWriteEndpointFailoverPolicyAutomatic), - string(sql.ReadWriteEndpointFailoverPolicyManual), + string(instancefailovergroups.ReadWriteEndpointFailoverPolicyAutomatic), + string(instancefailovergroups.ReadWriteEndpointFailoverPolicyManual), }, false), }, @@ -151,13 +154,13 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Create() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - managedInstanceId, err := parse.ManagedInstanceID(model.ManagedInstanceId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(model.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `managed_instance_id`: %v", err) + return err } - id := parse.NewInstanceFailoverGroupID(managedInstanceId.SubscriptionId, - managedInstanceId.ResourceGroup, model.Location, model.Name) + id := instancefailovergroups.NewInstanceFailoverGroupID(managedInstanceId.SubscriptionId, + managedInstanceId.ResourceGroupName, model.Location, model.Name) partnerId, err := parse.ManagedInstanceID(model.PartnerManagedInstanceId) if err != nil { @@ -171,58 +174,54 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Create() sdk.ResourceFunc { } metadata.Logger.Infof("Import check for %s", id) - existing, err := client.Get(ctx, id.ResourceGroup, id.LocationName, id.Name) - if err != nil && !utils.ResponseWasNotFound(existing.Response) { + 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 !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - readOnlyFailoverPolicy := sql.ReadOnlyEndpointFailoverPolicyDisabled + readOnlyFailoverPolicy := instancefailovergroups.ReadOnlyEndpointFailoverPolicyDisabled if model.ReadOnlyEndpointFailoverPolicyEnabled { - readOnlyFailoverPolicy = sql.ReadOnlyEndpointFailoverPolicyEnabled + readOnlyFailoverPolicy = instancefailovergroups.ReadOnlyEndpointFailoverPolicyEnabled } - parameters := sql.InstanceFailoverGroup{ - InstanceFailoverGroupProperties: &sql.InstanceFailoverGroupProperties{ - ReadOnlyEndpoint: &sql.InstanceFailoverGroupReadOnlyEndpoint{ - FailoverPolicy: readOnlyFailoverPolicy, + parameters := instancefailovergroups.InstanceFailoverGroup{ + Properties: &instancefailovergroups.InstanceFailoverGroupProperties{ + ReadOnlyEndpoint: &instancefailovergroups.InstanceFailoverGroupReadOnlyEndpoint{ + FailoverPolicy: &readOnlyFailoverPolicy, }, - ReadWriteEndpoint: &sql.InstanceFailoverGroupReadWriteEndpoint{}, - PartnerRegions: &[]sql.PartnerRegionInfo{ + ReadWriteEndpoint: instancefailovergroups.InstanceFailoverGroupReadWriteEndpoint{}, + PartnerRegions: []instancefailovergroups.PartnerRegionInfo{ { Location: partner.Location, }, }, - ManagedInstancePairs: &[]sql.ManagedInstancePairInfo{ + ManagedInstancePairs: []instancefailovergroups.ManagedInstancePairInfo{ { - PrimaryManagedInstanceID: utils.String(managedInstanceId.ID()), - PartnerManagedInstanceID: utils.String(partnerId.ID()), + PrimaryManagedInstanceId: utils.String(managedInstanceId.ID()), + PartnerManagedInstanceId: utils.String(partnerId.ID()), }, }, }, } if rwPolicy := model.ReadWriteEndpointFailurePolicy; len(rwPolicy) > 0 { - parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint.FailoverPolicy = sql.ReadWriteEndpointFailoverPolicy(rwPolicy[0].Mode) - if rwPolicy[0].Mode == string(sql.ReadWriteEndpointFailoverPolicyAutomatic) { - parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes = utils.Int32(int32(rwPolicy[0].GraceMinutes)) + parameters.Properties.ReadWriteEndpoint.FailoverPolicy = instancefailovergroups.ReadWriteEndpointFailoverPolicy(rwPolicy[0].Mode) + if rwPolicy[0].Mode == string(instancefailovergroups.ReadWriteEndpointFailoverPolicyAutomatic) { + parameters.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes = &rwPolicy[0].GraceMinutes } } metadata.Logger.Infof("Creating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.LocationName, id.Name, parameters) + err = client.CreateOrUpdateThenPoll(ctx, id, parameters) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - metadata.SetID(id) return nil @@ -236,7 +235,7 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Update() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstanceFailoverGroupsClient - id, err := parse.InstanceFailoverGroupID(metadata.ResourceData.Id()) + id, err := instancefailovergroups.ParseInstanceFailoverGroupID(metadata.ResourceData.Id()) if err != nil { return err } @@ -247,9 +246,9 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Update() sdk.ResourceFunc { return err } - managedInstanceId, err := parse.ManagedInstanceID(state.ManagedInstanceId) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(state.ManagedInstanceId) if err != nil { - return fmt.Errorf("parsing `managed_instance_id`: %v", err) + return err } partnerId, err := parse.ManagedInstanceID(state.PartnerManagedInstanceId) @@ -263,49 +262,45 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Update() sdk.ResourceFunc { return fmt.Errorf("checking for existence and region of Partner of %q: %+v", id, err) } - readOnlyFailoverPolicy := sql.ReadOnlyEndpointFailoverPolicyDisabled + readOnlyFailoverPolicy := instancefailovergroups.ReadOnlyEndpointFailoverPolicyDisabled if state.ReadOnlyEndpointFailoverPolicyEnabled { - readOnlyFailoverPolicy = sql.ReadOnlyEndpointFailoverPolicyEnabled + readOnlyFailoverPolicy = instancefailovergroups.ReadOnlyEndpointFailoverPolicyEnabled } - parameters := sql.InstanceFailoverGroup{ - InstanceFailoverGroupProperties: &sql.InstanceFailoverGroupProperties{ - ReadOnlyEndpoint: &sql.InstanceFailoverGroupReadOnlyEndpoint{ - FailoverPolicy: readOnlyFailoverPolicy, + parameters := instancefailovergroups.InstanceFailoverGroup{ + Properties: &instancefailovergroups.InstanceFailoverGroupProperties{ + ReadOnlyEndpoint: &instancefailovergroups.InstanceFailoverGroupReadOnlyEndpoint{ + FailoverPolicy: &readOnlyFailoverPolicy, }, - ReadWriteEndpoint: &sql.InstanceFailoverGroupReadWriteEndpoint{}, - PartnerRegions: &[]sql.PartnerRegionInfo{ + ReadWriteEndpoint: instancefailovergroups.InstanceFailoverGroupReadWriteEndpoint{}, + PartnerRegions: []instancefailovergroups.PartnerRegionInfo{ { Location: partner.Location, }, }, - ManagedInstancePairs: &[]sql.ManagedInstancePairInfo{ + ManagedInstancePairs: []instancefailovergroups.ManagedInstancePairInfo{ { - PrimaryManagedInstanceID: utils.String(managedInstanceId.ID()), - PartnerManagedInstanceID: utils.String(partnerId.ID()), + PrimaryManagedInstanceId: utils.String(managedInstanceId.ID()), + PartnerManagedInstanceId: utils.String(partnerId.ID()), }, }, }, } if rwPolicy := state.ReadWriteEndpointFailurePolicy; len(rwPolicy) > 0 { - parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint.FailoverPolicy = sql.ReadWriteEndpointFailoverPolicy(rwPolicy[0].Mode) - if rwPolicy[0].Mode == string(sql.ReadWriteEndpointFailoverPolicyAutomatic) { - parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes = utils.Int32(int32(rwPolicy[0].GraceMinutes)) + parameters.Properties.ReadWriteEndpoint.FailoverPolicy = instancefailovergroups.ReadWriteEndpointFailoverPolicy(rwPolicy[0].Mode) + if rwPolicy[0].Mode == string(instancefailovergroups.ReadWriteEndpointFailoverPolicyAutomatic) { + parameters.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes = &rwPolicy[0].GraceMinutes } } metadata.Logger.Infof("Updating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.LocationName, id.Name, parameters) + err = client.CreateOrUpdateThenPoll(ctx, *id, parameters) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", id, err) - } - return nil }, } @@ -317,7 +312,7 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Read() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstanceFailoverGroupsClient - id, err := parse.InstanceFailoverGroupID(metadata.ResourceData.Id()) + id, err := instancefailovergroups.ParseInstanceFailoverGroupID(metadata.ResourceData.Id()) if err != nil { return err } @@ -328,44 +323,44 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Read() sdk.ResourceFunc { return err } - result, err := client.Get(ctx, id.ResourceGroup, id.LocationName, id.Name) + result, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(result.Response) { + if response.WasNotFound(result.HttpResponse) { return metadata.MarkAsGone(id) } return fmt.Errorf("retrieving %s: %v", id, err) } model := MsSqlManagedInstanceFailoverGroupModel{ - Name: id.Name, + Name: id.InstanceFailoverGroupName, Location: id.LocationName, } - if props := result.InstanceFailoverGroupProperties; props != nil { - model.Role = string(props.ReplicationRole) + if result.Model != nil { + if props := result.Model.Properties; props != nil { + model.Role = string(pointer.From(props.ReplicationRole)) + + if instancePairs := props.ManagedInstancePairs; len(instancePairs) == 1 { + if primaryId := instancePairs[0].PrimaryManagedInstanceId; primaryId != nil { + id, err := parse.ManagedInstanceIDInsensitively(*primaryId) + if err != nil { + return fmt.Errorf("parsing `PrimaryManagedInstanceID` from response: %v", err) + } - if instancePairs := props.ManagedInstancePairs; instancePairs != nil && len(*instancePairs) == 1 { - if primaryId := (*instancePairs)[0].PrimaryManagedInstanceID; primaryId != nil { - id, err := parse.ManagedInstanceIDInsensitively(*primaryId) - if err != nil { - return fmt.Errorf("parsing `PrimaryManagedInstanceID` from response: %v", err) + model.ManagedInstanceId = id.ID() } - model.ManagedInstanceId = id.ID() - } + if partnerId := instancePairs[0].PartnerManagedInstanceId; partnerId != nil { + id, err := parse.ManagedInstanceIDInsensitively(*partnerId) + if err != nil { + return fmt.Errorf("parsing `PrimaryManagedInstanceID` from response: %v", err) + } - if partnerId := (*instancePairs)[0].PartnerManagedInstanceID; partnerId != nil { - id, err := parse.ManagedInstanceIDInsensitively(*partnerId) - if err != nil { - return fmt.Errorf("parsing `PrimaryManagedInstanceID` from response: %v", err) + model.PartnerManagedInstanceId = id.ID() } - - model.PartnerManagedInstanceId = id.ID() } - } - if partnerRegions := props.PartnerRegions; partnerRegions != nil { - for _, partnerRegion := range *partnerRegions { + for _, partnerRegion := range props.PartnerRegions { var location string if partnerRegion.Location != nil { location = *partnerRegion.Location @@ -373,27 +368,20 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Read() sdk.ResourceFunc { model.PartnerRegion = append(model.PartnerRegion, MsSqlManagedInstancePartnerRegionModel{ Location: location, - Role: string(partnerRegion.ReplicationRole), + Role: string(pointer.From(partnerRegion.ReplicationRole)), }) } - } - - if readOnlyEndpoint := props.ReadOnlyEndpoint; readOnlyEndpoint != nil { - if readOnlyEndpoint.FailoverPolicy == sql.ReadOnlyEndpointFailoverPolicyEnabled { - model.ReadOnlyEndpointFailoverPolicyEnabled = true - } - } - if readWriteEndpoint := props.ReadWriteEndpoint; readWriteEndpoint != nil { - var graceMinutes int64 - if readWriteEndpoint.FailoverWithDataLossGracePeriodMinutes != nil { - graceMinutes = int64(*readWriteEndpoint.FailoverWithDataLossGracePeriodMinutes) + if readOnlyEndpoint := props.ReadOnlyEndpoint; readOnlyEndpoint != nil { + if *readOnlyEndpoint.FailoverPolicy == instancefailovergroups.ReadOnlyEndpointFailoverPolicyEnabled { + model.ReadOnlyEndpointFailoverPolicyEnabled = true + } } model.ReadWriteEndpointFailurePolicy = []MsSqlManagedInstanceReadWriteEndpointFailurePolicyModel{ { - Mode: string(readWriteEndpoint.FailoverPolicy), - GraceMinutes: graceMinutes, + Mode: string(props.ReadWriteEndpoint.FailoverPolicy), + GraceMinutes: pointer.From(props.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes), }, } } @@ -410,18 +398,14 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Delete() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstanceFailoverGroupsClient - id, err := parse.InstanceFailoverGroupID(metadata.ResourceData.Id()) + id, err := instancefailovergroups.ParseInstanceFailoverGroupID(metadata.ResourceData.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.LocationName, id.Name) + err = client.DeleteThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", id, err) + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource_test.go index d0bf36b5727f..271d16afc139 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_failover_group_resource_test.go @@ -8,10 +8,11 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -52,14 +53,14 @@ func TestAccMsSqlManagedInstanceFailoverGroup_update(t *testing.T) { } func (r MsSqlManagedInstanceFailoverGroupResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ManagedInstanceFailoverGroupID(state.ID) + id, err := instancefailovergroups.ParseInstanceFailoverGroupID(state.ID) if err != nil { return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstanceFailoverGroupsClient.Get(ctx, id.ResourceGroup, id.LocationName, id.InstanceFailoverGroupName) + resp, err := client.MSSQLManagedInstance.ManagedInstanceFailoverGroupsClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving %s: %+v", id, err) diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource.go index 9243bf7e1985..3e841d2191c6 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" @@ -18,14 +17,20 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/maintenance/2023-04-01/publicmaintenanceconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/sql/parse" "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" - "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +const ( + StorageAccountTypeGRS = "GRS" + StorageAccountTypeLRS = "LRS" + StorageAccountTypeZRS = "ZRS" + StorageAccountTypeGZRS = "GZRS" ) type MsSqlManagedInstanceModel struct { @@ -201,11 +206,11 @@ func (r MsSqlManagedInstanceResource) Arguments() map[string]*pluginsdk.Schema { "proxy_override": { Type: schema.TypeString, Optional: true, - Default: string(sql.ManagedInstanceProxyOverrideDefault), + Default: string(managedinstances.ManagedInstanceProxyOverrideDefault), ValidateFunc: validation.StringInSlice([]string{ - string(sql.ManagedInstanceProxyOverrideDefault), - string(sql.ManagedInstanceProxyOverrideRedirect), - string(sql.ManagedInstanceProxyOverrideProxy), + string(managedinstances.ManagedInstanceProxyOverrideDefault), + string(managedinstances.ManagedInstanceProxyOverrideRedirect), + string(managedinstances.ManagedInstanceProxyOverrideProxy), }, false), }, @@ -219,12 +224,12 @@ func (r MsSqlManagedInstanceResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - Default: string(sql.StorageAccountTypeGRS), + Default: StorageAccountTypeGRS, ValidateFunc: validation.StringInSlice([]string{ - string(sql.StorageAccountTypeGRS), - string(sql.StorageAccountTypeLRS), - string(sql.StorageAccountTypeZRS), - "GZRS", // manually adding until resource is ported to go-azure-sdk and we can upgrade to a newer API version + StorageAccountTypeGRS, + StorageAccountTypeLRS, + StorageAccountTypeZRS, + StorageAccountTypeGZRS, }, false), }, @@ -296,15 +301,15 @@ func (r MsSqlManagedInstanceResource) Create() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - id := parse.NewManagedInstanceID(subscriptionId, model.ResourceGroupName, model.Name) + id := commonids.NewSqlManagedInstanceID(subscriptionId, model.ResourceGroupName, model.Name) metadata.Logger.Infof("Import check for %s", id) - existing, err := client.Get(ctx, id.ResourceGroup, id.Name, "") - if err != nil && !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.Get(ctx, id, managedinstances.GetOperationOptions{}) + if err != nil && !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) } @@ -315,52 +320,44 @@ func (r MsSqlManagedInstanceResource) Create() sdk.ResourceFunc { maintenanceConfigId := publicmaintenanceconfigurations.NewPublicMaintenanceConfigurationID(subscriptionId, model.MaintenanceConfigurationName) - parameters := sql.ManagedInstance{ + parameters := managedinstances.ManagedInstance{ Sku: sku, Identity: r.expandIdentity(model.Identity), - Location: pointer.To(location.Normalize(model.Location)), - ManagedInstanceProperties: &sql.ManagedInstanceProperties{ - AdministratorLogin: pointer.To(model.AdministratorLogin), - AdministratorLoginPassword: pointer.To(model.AdministratorLoginPassword), - Collation: pointer.To(model.Collation), - DNSZonePartner: pointer.To(model.DnsZonePartnerId), - LicenseType: sql.ManagedInstanceLicenseType(model.LicenseType), - MaintenanceConfigurationID: pointer.To(maintenanceConfigId.ID()), - MinimalTLSVersion: pointer.To(model.MinimumTlsVersion), - ProxyOverride: sql.ManagedInstanceProxyOverride(model.ProxyOverride), - PublicDataEndpointEnabled: pointer.To(model.PublicDataEndpointEnabled), - StorageAccountType: sql.StorageAccountType(model.StorageAccountType), - StorageSizeInGB: pointer.To(int32(model.StorageSizeInGb)), - SubnetID: pointer.To(model.SubnetId), - TimezoneID: pointer.To(model.TimezoneId), - VCores: pointer.To(int32(model.VCores)), - ZoneRedundant: pointer.To(model.ZoneRedundantEnabled), + Location: location.Normalize(model.Location), + Properties: &managedinstances.ManagedInstanceProperties{ + AdministratorLogin: pointer.To(model.AdministratorLogin), + AdministratorLoginPassword: pointer.To(model.AdministratorLoginPassword), + Collation: pointer.To(model.Collation), + DnsZonePartner: pointer.To(model.DnsZonePartnerId), + LicenseType: pointer.To(managedinstances.ManagedInstanceLicenseType(model.LicenseType)), + MaintenanceConfigurationId: pointer.To(maintenanceConfigId.ID()), + MinimalTlsVersion: pointer.To(model.MinimumTlsVersion), + ProxyOverride: pointer.To(managedinstances.ManagedInstanceProxyOverride(model.ProxyOverride)), + PublicDataEndpointEnabled: pointer.To(model.PublicDataEndpointEnabled), + RequestedBackupStorageRedundancy: pointer.To(storageAccTypeToBackupStorageRedundancy(model.StorageAccountType)), + StorageSizeInGB: pointer.To(model.StorageSizeInGb), + SubnetId: pointer.To(model.SubnetId), + TimezoneId: pointer.To(model.TimezoneId), + VCores: pointer.To(model.VCores), + ZoneRedundant: pointer.To(model.ZoneRedundantEnabled), }, - Tags: tags.FromTypedObject(model.Tags), + Tags: pointer.To(model.Tags), } - if parameters.Identity != nil && len(parameters.Identity.UserAssignedIdentities) > 0 { - for k := range parameters.Identity.UserAssignedIdentities { - parameters.ManagedInstanceProperties.PrimaryUserAssignedIdentityID = pointer.To(k) + if parameters.Identity != nil && len(parameters.Identity.IdentityIds) > 0 { + for k := range parameters.Identity.IdentityIds { + parameters.Properties.PrimaryUserAssignedIdentityId = pointer.To(k) break } } metadata.Logger.Infof("Creating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, parameters) + err = client.CreateOrUpdateThenPoll(ctx, id, parameters) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - if response.WasConflict(future.Response()) { - return fmt.Errorf("sql managed instance names need to be globally unique and %q is already in use", id.Name) - } - - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - metadata.SetID(id) return nil }, @@ -373,7 +370,7 @@ func (r MsSqlManagedInstanceResource) Update() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstancesClient - id, err := parse.ManagedInstanceID(metadata.ResourceData.Id()) + id, err := commonids.ParseSqlManagedInstanceID(metadata.ResourceData.Id()) if err != nil { return err } @@ -391,50 +388,46 @@ func (r MsSqlManagedInstanceResource) Update() sdk.ResourceFunc { return fmt.Errorf("expanding `sku_name` for SQL Managed Instance Server %q: %v", id.ID(), err) } - properties := sql.ManagedInstance{ + properties := managedinstances.ManagedInstance{ Sku: sku, Identity: r.expandIdentity(state.Identity), - Location: pointer.To(location.Normalize(state.Location)), - ManagedInstanceProperties: &sql.ManagedInstanceProperties{ - DNSZonePartner: pointer.To(state.DnsZonePartnerId), - LicenseType: sql.ManagedInstanceLicenseType(state.LicenseType), - MinimalTLSVersion: pointer.To(state.MinimumTlsVersion), - ProxyOverride: sql.ManagedInstanceProxyOverride(state.ProxyOverride), + Location: location.Normalize(state.Location), + Properties: &managedinstances.ManagedInstanceProperties{ + DnsZonePartner: pointer.To(state.DnsZonePartnerId), + LicenseType: pointer.To(managedinstances.ManagedInstanceLicenseType(state.LicenseType)), + MinimalTlsVersion: pointer.To(state.MinimumTlsVersion), + ProxyOverride: pointer.To(managedinstances.ManagedInstanceProxyOverride(state.ProxyOverride)), PublicDataEndpointEnabled: pointer.To(state.PublicDataEndpointEnabled), - StorageSizeInGB: pointer.To(int32(state.StorageSizeInGb)), - VCores: pointer.To(int32(state.VCores)), + StorageSizeInGB: pointer.To(state.StorageSizeInGb), + VCores: pointer.To(state.VCores), ZoneRedundant: pointer.To(state.ZoneRedundantEnabled), }, - Tags: tags.FromTypedObject(state.Tags), + Tags: pointer.To(state.Tags), } - if properties.Identity != nil && len(properties.Identity.UserAssignedIdentities) > 0 { - for k := range properties.Identity.UserAssignedIdentities { - properties.ManagedInstanceProperties.PrimaryUserAssignedIdentityID = pointer.To(k) + if properties.Identity != nil && len(properties.Identity.IdentityIds) > 0 { + for k := range properties.Identity.IdentityIds { + properties.Properties.PrimaryUserAssignedIdentityId = pointer.To(k) break } } if metadata.ResourceData.HasChange("maintenance_configuration_name") { maintenanceConfigId := publicmaintenanceconfigurations.NewPublicMaintenanceConfigurationID(id.SubscriptionId, state.MaintenanceConfigurationName) - properties.MaintenanceConfigurationID = pointer.To(maintenanceConfigId.ID()) + properties.Properties.MaintenanceConfigurationId = pointer.To(maintenanceConfigId.ID()) } if metadata.ResourceData.HasChange("administrator_login_password") { - properties.AdministratorLoginPassword = pointer.To(state.AdministratorLoginPassword) + properties.Properties.AdministratorLoginPassword = pointer.To(state.AdministratorLoginPassword) } metadata.Logger.Infof("Updating %s", id) - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, properties) + err = client.CreateOrUpdateThenPoll(ctx, *id, properties) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", id, err) - } - return nil }, } @@ -446,7 +439,7 @@ func (r MsSqlManagedInstanceResource) Read() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstancesClient - id, err := parse.ManagedInstanceID(metadata.ResourceData.Id()) + id, err := commonids.ParseSqlManagedInstanceID(metadata.ResourceData.Id()) if err != nil { return err } @@ -457,79 +450,62 @@ func (r MsSqlManagedInstanceResource) Read() sdk.ResourceFunc { return err } - existing, err := client.Get(ctx, id.ResourceGroup, id.Name, "") + existing, err := client.Get(ctx, *id, managedinstances.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(existing.Response) { + if response.WasNotFound(existing.HttpResponse) { return metadata.MarkAsGone(id) } return fmt.Errorf("retrieving %s: %v", id, err) } + model := MsSqlManagedInstanceModel{} - model := MsSqlManagedInstanceModel{ - Name: id.Name, - Location: location.NormalizeNilable(existing.Location), - ResourceGroupName: id.ResourceGroup, - Identity: r.flattenIdentity(existing.Identity), - Tags: tags.ToTypedObject(existing.Tags), - - // This value is not returned, so we'll just set whatever is in the state/config - AdministratorLoginPassword: state.AdministratorLoginPassword, - // This value is not returned, so we'll just set whatever is in the state/config - DnsZonePartnerId: state.DnsZonePartnerId, - } + if existing.Model != nil { - if sku := existing.Sku; sku != nil && sku.Name != nil { - model.SkuName = r.normalizeSku(*sku.Name) - } + model = MsSqlManagedInstanceModel{ + Name: id.ManagedInstanceName, + Location: location.NormalizeNilable(&existing.Model.Location), + ResourceGroupName: id.ResourceGroupName, + Identity: r.flattenIdentity(existing.Model.Identity), + Tags: pointer.From(existing.Model.Tags), - if props := existing.ManagedInstanceProperties; props != nil { - model.LicenseType = string(props.LicenseType) - model.ProxyOverride = string(props.ProxyOverride) - model.StorageAccountType = string(props.StorageAccountType) - - if props.AdministratorLogin != nil { - model.AdministratorLogin = *props.AdministratorLogin - } - if props.Collation != nil { - model.Collation = *props.Collation - } - if props.DNSZone != nil { - model.DnsZone = *props.DNSZone + // This value is not returned, so we'll just set whatever is in the state/config + AdministratorLoginPassword: state.AdministratorLoginPassword, + // This value is not returned, so we'll just set whatever is in the state/config + DnsZonePartnerId: state.DnsZonePartnerId, } - if props.FullyQualifiedDomainName != nil { - model.Fqdn = *props.FullyQualifiedDomainName + + if sku := existing.Model.Sku; sku != nil { + model.SkuName = r.normalizeSku(sku.Name) } - if props.MaintenanceConfigurationID != nil { - maintenanceConfigId, err := publicmaintenanceconfigurations.ParsePublicMaintenanceConfigurationIDInsensitively(*props.MaintenanceConfigurationID) - if err != nil { - return err + + if props := existing.Model.Properties; props != nil { + model.LicenseType = string(pointer.From(props.LicenseType)) + model.ProxyOverride = string(pointer.From(props.ProxyOverride)) + model.StorageAccountType = backupStorageRedundancyToStorageAccType(pointer.From(props.RequestedBackupStorageRedundancy)) + + model.AdministratorLogin = pointer.From(props.AdministratorLogin) + model.Collation = pointer.From(props.Collation) + model.DnsZone = pointer.From(props.DnsZone) + model.Fqdn = pointer.From(props.FullyQualifiedDomainName) + + if props.MaintenanceConfigurationId != nil { + maintenanceConfigId, err := publicmaintenanceconfigurations.ParsePublicMaintenanceConfigurationIDInsensitively(*props.MaintenanceConfigurationId) + if err != nil { + return err + } + model.MaintenanceConfigurationName = maintenanceConfigId.PublicMaintenanceConfigurationName } - model.MaintenanceConfigurationName = maintenanceConfigId.PublicMaintenanceConfigurationName - } - if props.MinimalTLSVersion != nil { - model.MinimumTlsVersion = *props.MinimalTLSVersion - } - if props.PublicDataEndpointEnabled != nil { - model.PublicDataEndpointEnabled = *props.PublicDataEndpointEnabled - } - if props.StorageSizeInGB != nil { - model.StorageSizeInGb = int64(*props.StorageSizeInGB) - } - if props.SubnetID != nil { - model.SubnetId = *props.SubnetID - } - if props.TimezoneID != nil { - model.TimezoneId = *props.TimezoneID - } - if props.VCores != nil { - model.VCores = int64(*props.VCores) - } - if props.ZoneRedundant != nil { - model.ZoneRedundantEnabled = *props.ZoneRedundant + model.MinimumTlsVersion = pointer.From(props.MinimalTlsVersion) + model.PublicDataEndpointEnabled = pointer.From(props.PublicDataEndpointEnabled) + model.StorageSizeInGb = pointer.From(props.StorageSizeInGB) + model.SubnetId = pointer.From(props.SubnetId) + model.TimezoneId = pointer.From(props.TimezoneId) + model.VCores = pointer.From(props.VCores) + model.ZoneRedundantEnabled = pointer.From(props.ZoneRedundant) } - } + } return metadata.Encode(&model) }, } @@ -541,18 +517,14 @@ func (r MsSqlManagedInstanceResource) Delete() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.MSSQLManagedInstance.ManagedInstancesClient - id, err := parse.ManagedInstanceID(metadata.ResourceData.Id()) + id, err := commonids.ParseSqlManagedInstanceID(metadata.ResourceData.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + err = client.DeleteThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", id, err) + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil @@ -560,7 +532,7 @@ func (r MsSqlManagedInstanceResource) Delete() sdk.ResourceFunc { } } -func (r MsSqlManagedInstanceResource) expandIdentity(input []identity.SystemOrUserAssignedList) *sql.ResourceIdentity { +func (r MsSqlManagedInstanceResource) expandIdentity(input []identity.SystemOrUserAssignedList) *identity.LegacySystemAndUserAssignedMap { if len(input) == 0 { return nil } @@ -570,37 +542,27 @@ func (r MsSqlManagedInstanceResource) expandIdentity(input []identity.SystemOrUs return nil } - var identityIds map[string]*sql.UserIdentity + var identityIds map[string]identity.UserAssignedIdentityDetails if len(input[0].IdentityIds) != 0 { - identityIds = map[string]*sql.UserIdentity{} + identityIds = map[string]identity.UserAssignedIdentityDetails{} for _, id := range input[0].IdentityIds { - identityIds[id] = &sql.UserIdentity{} + identityIds[id] = identity.UserAssignedIdentityDetails{} } } - return &sql.ResourceIdentity{ - Type: sql.IdentityType(input[0].Type), - UserAssignedIdentities: identityIds, + return &identity.LegacySystemAndUserAssignedMap{ + Type: input[0].Type, + IdentityIds: identityIds, } } -func (r MsSqlManagedInstanceResource) flattenIdentity(input *sql.ResourceIdentity) []identity.SystemOrUserAssignedList { +func (r MsSqlManagedInstanceResource) flattenIdentity(input *identity.LegacySystemAndUserAssignedMap) []identity.SystemOrUserAssignedList { if input == nil { return nil } - principalId := "" - if input.PrincipalID != nil { - principalId = input.PrincipalID.String() - } - - tenantId := "" - if input.TenantID != nil { - tenantId = input.TenantID.String() - } - var identityIds = make([]string, 0) - for k := range input.UserAssignedIdentities { + for k := range input.IdentityIds { parsedId, err := commonids.ParseUserAssignedIdentityIDInsensitively(k) if err != nil { continue @@ -609,14 +571,14 @@ func (r MsSqlManagedInstanceResource) flattenIdentity(input *sql.ResourceIdentit } return []identity.SystemOrUserAssignedList{{ - Type: identity.Type(input.Type), - PrincipalId: principalId, - TenantId: tenantId, + Type: input.Type, + PrincipalId: input.PrincipalId, + TenantId: input.TenantId, IdentityIds: identityIds, }} } -func (r MsSqlManagedInstanceResource) expandSkuName(skuName string) (*sql.Sku, error) { +func (r MsSqlManagedInstanceResource) expandSkuName(skuName string) (*managedinstances.Sku, error) { parts := strings.Split(skuName, "_") if len(parts) != 2 { return nil, fmt.Errorf("sku_name (%s) has the wrong number of parts (%d) after splitting on _", skuName, len(parts)) @@ -632,8 +594,8 @@ func (r MsSqlManagedInstanceResource) expandSkuName(skuName string) (*sql.Sku, e return nil, fmt.Errorf("sku_name %s has unknown sku tier %s", skuName, parts[0]) } - return &sql.Sku{ - Name: pointer.To(skuName), + return &managedinstances.Sku{ + Name: skuName, Tier: pointer.To(tier), Family: pointer.To(parts[1]), }, nil @@ -653,3 +615,32 @@ func (r MsSqlManagedInstanceResource) normalizeSku(sku string) string { return sku } + +// the StorageAccountType property has changed to RequestedBackupStorageRedundancy with 1-1 mapping of the following values: +// GRS -> Geo +// ZRS -> Zone +// LRS -> Local +// GZRS -> GeoZone +func storageAccTypeToBackupStorageRedundancy(storageAccountType string) managedinstances.BackupStorageRedundancy { + switch storageAccountType { + case StorageAccountTypeZRS: + return managedinstances.BackupStorageRedundancyZone + case StorageAccountTypeLRS: + return managedinstances.BackupStorageRedundancyLocal + case StorageAccountTypeGZRS: + return managedinstances.BackupStorageRedundancyGeoZone + } + return managedinstances.BackupStorageRedundancyGeo +} + +func backupStorageRedundancyToStorageAccType(backupStorageRedundancy managedinstances.BackupStorageRedundancy) string { + switch backupStorageRedundancy { + case managedinstances.BackupStorageRedundancyZone: + return StorageAccountTypeZRS + case managedinstances.BackupStorageRedundancyLocal: + return StorageAccountTypeLRS + case managedinstances.BackupStorageRedundancyGeoZone: + return StorageAccountTypeGZRS + } + return StorageAccountTypeGRS +} diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource_test.go index a09ee4bea6e2..7bd2de9a0ffe 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_resource_test.go @@ -8,1001 +8,18 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) type MsSqlManagedInstanceResource struct{} -const managedInstanceStaticRoutes = ` - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-OneDsCollector" - address_prefix = "OneDsCollector" - next_hop_type = "Internet" - } - route { - name = "mi-13-64-11-nexthop-internet" - address_prefix = "13.64.0.0/11" - next_hop_type = "Internet" - } - route { - name = "mi-13-104-14-nexthop-internet" - address_prefix = "13.104.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-20-34-15-nexthop-internet" - address_prefix = "20.34.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-20-36-14-nexthop-internet" - address_prefix = "20.36.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-20-40-13-nexthop-internet" - address_prefix = "20.40.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-20-128-16-nexthop-internet" - address_prefix = "20.128.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-20-140-15-nexthop-internet" - address_prefix = "20.140.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-20-144-14-nexthop-internet" - address_prefix = "20.144.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-20-150-15-nexthop-internet" - address_prefix = "20.150.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-20-160-12-nexthop-internet" - address_prefix = "20.160.0.0/12" - next_hop_type = "Internet" - } - route { - name = "mi-20-176-14-nexthop-internet" - address_prefix = "20.176.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-20-180-14-nexthop-internet" - address_prefix = "20.180.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-20-184-13-nexthop-internet" - address_prefix = "20.184.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-40-64-10-nexthop-internet" - address_prefix = "40.64.0.0/10" - next_hop_type = "Internet" - } - route { - name = "mi-51-4-15-nexthop-internet" - address_prefix = "51.4.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-51-8-16-nexthop-internet" - address_prefix = "51.8.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-10-15-nexthop-internet" - address_prefix = "51.10.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-51-12-15-nexthop-internet" - address_prefix = "51.12.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-51-18-16-nexthop-internet" - address_prefix = "51.18.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-51-16-nexthop-internet" - address_prefix = "51.51.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-53-16-nexthop-internet" - address_prefix = "51.53.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-103-16-nexthop-internet" - address_prefix = "51.103.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-104-15-nexthop-internet" - address_prefix = "51.104.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-51-107-16-nexthop-internet" - address_prefix = "51.107.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-116-16-nexthop-internet" - address_prefix = "51.116.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-120-16-nexthop-internet" - address_prefix = "51.120.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-124-16-nexthop-internet" - address_prefix = "51.124.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-132-16-nexthop-internet" - address_prefix = "51.132.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-136-15-nexthop-internet" - address_prefix = "51.136.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-51-138-16-nexthop-internet" - address_prefix = "51.138.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-51-140-14-nexthop-internet" - address_prefix = "51.140.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-51-144-15-nexthop-internet" - address_prefix = "51.144.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-52-96-12-nexthop-internet" - address_prefix = "52.96.0.0/12" - next_hop_type = "Internet" - } - route { - name = "mi-52-112-14-nexthop-internet" - address_prefix = "52.112.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-52-125-16-nexthop-internet" - address_prefix = "52.125.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-52-126-15-nexthop-internet" - address_prefix = "52.126.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-52-130-15-nexthop-internet" - address_prefix = "52.130.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-52-132-14-nexthop-internet" - address_prefix = "52.132.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-52-136-13-nexthop-internet" - address_prefix = "52.136.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-52-145-16-nexthop-internet" - address_prefix = "52.145.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-52-146-15-nexthop-internet" - address_prefix = "52.146.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-52-148-14-nexthop-internet" - address_prefix = "52.148.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-52-152-13-nexthop-internet" - address_prefix = "52.152.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-52-160-11-nexthop-internet" - address_prefix = "52.160.0.0/11" - next_hop_type = "Internet" - } - route { - name = "mi-52-224-11-nexthop-internet" - address_prefix = "52.224.0.0/11" - next_hop_type = "Internet" - } - route { - name = "mi-64-4-18-nexthop-internet" - address_prefix = "64.4.0.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-65-52-14-nexthop-internet" - address_prefix = "65.52.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-66-119-144-20-nexthop-internet" - address_prefix = "66.119.144.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-70-37-17-nexthop-internet" - address_prefix = "70.37.0.0/17" - next_hop_type = "Internet" - } - route { - name = "mi-70-37-128-18-nexthop-internet" - address_prefix = "70.37.128.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-91-190-216-21-nexthop-internet" - address_prefix = "91.190.216.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-94-245-64-18-nexthop-internet" - address_prefix = "94.245.64.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-103-9-8-22-nexthop-internet" - address_prefix = "103.9.8.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-103-25-156-24-nexthop-internet" - address_prefix = "103.25.156.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-103-25-157-24-nexthop-internet" - address_prefix = "103.25.157.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-103-25-158-23-nexthop-internet" - address_prefix = "103.25.158.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-103-36-96-22-nexthop-internet" - address_prefix = "103.36.96.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-103-255-140-22-nexthop-internet" - address_prefix = "103.255.140.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-104-40-13-nexthop-internet" - address_prefix = "104.40.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-104-146-15-nexthop-internet" - address_prefix = "104.146.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-104-208-13-nexthop-internet" - address_prefix = "104.208.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-111-221-16-20-nexthop-internet" - address_prefix = "111.221.16.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-111-221-64-18-nexthop-internet" - address_prefix = "111.221.64.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-129-75-16-nexthop-internet" - address_prefix = "129.75.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-1-24-nexthop-internet" - address_prefix = "131.253.1.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-3-24-nexthop-internet" - address_prefix = "131.253.3.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-5-24-nexthop-internet" - address_prefix = "131.253.5.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-6-24-nexthop-internet" - address_prefix = "131.253.6.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-8-24-nexthop-internet" - address_prefix = "131.253.8.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-12-22-nexthop-internet" - address_prefix = "131.253.12.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-16-23-nexthop-internet" - address_prefix = "131.253.16.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-18-24-nexthop-internet" - address_prefix = "131.253.18.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-21-24-nexthop-internet" - address_prefix = "131.253.21.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-22-23-nexthop-internet" - address_prefix = "131.253.22.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-24-21-nexthop-internet" - address_prefix = "131.253.24.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-32-20-nexthop-internet" - address_prefix = "131.253.32.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-61-24-nexthop-internet" - address_prefix = "131.253.61.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-62-23-nexthop-internet" - address_prefix = "131.253.62.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-64-18-nexthop-internet" - address_prefix = "131.253.64.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-131-253-128-17-nexthop-internet" - address_prefix = "131.253.128.0/17" - next_hop_type = "Internet" - } - route { - name = "mi-132-245-16-nexthop-internet" - address_prefix = "132.245.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-134-170-16-nexthop-internet" - address_prefix = "134.170.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-134-177-16-nexthop-internet" - address_prefix = "134.177.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-137-116-15-nexthop-internet" - address_prefix = "137.116.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-137-135-16-nexthop-internet" - address_prefix = "137.135.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-138-91-16-nexthop-internet" - address_prefix = "138.91.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-138-196-16-nexthop-internet" - address_prefix = "138.196.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-139-217-16-nexthop-internet" - address_prefix = "139.217.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-139-219-16-nexthop-internet" - address_prefix = "139.219.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-141-251-16-nexthop-internet" - address_prefix = "141.251.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-146-147-16-nexthop-internet" - address_prefix = "146.147.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-147-243-16-nexthop-internet" - address_prefix = "147.243.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-150-171-16-nexthop-internet" - address_prefix = "150.171.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-150-242-48-22-nexthop-internet" - address_prefix = "150.242.48.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-157-54-15-nexthop-internet" - address_prefix = "157.54.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-157-56-14-nexthop-internet" - address_prefix = "157.56.0.0/14" - next_hop_type = "Internet" - } - route { - name = "mi-157-60-16-nexthop-internet" - address_prefix = "157.60.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-167-220-16-nexthop-internet" - address_prefix = "167.220.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-168-61-16-nexthop-internet" - address_prefix = "168.61.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-168-62-15-nexthop-internet" - address_prefix = "168.62.0.0/15" - next_hop_type = "Internet" - } - route { - name = "mi-191-232-13-nexthop-internet" - address_prefix = "191.232.0.0/13" - next_hop_type = "Internet" - } - route { - name = "mi-192-32-16-nexthop-internet" - address_prefix = "192.32.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-192-48-225-24-nexthop-internet" - address_prefix = "192.48.225.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-192-84-159-24-nexthop-internet" - address_prefix = "192.84.159.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-192-84-160-23-nexthop-internet" - address_prefix = "192.84.160.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-192-100-102-24-nexthop-internet" - address_prefix = "192.100.102.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-192-100-103-24-nexthop-internet" - address_prefix = "192.100.103.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-192-197-157-24-nexthop-internet" - address_prefix = "192.197.157.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-193-149-64-19-nexthop-internet" - address_prefix = "193.149.64.0/19" - next_hop_type = "Internet" - } - route { - name = "mi-193-221-113-24-nexthop-internet" - address_prefix = "193.221.113.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-194-69-96-19-nexthop-internet" - address_prefix = "194.69.96.0/19" - next_hop_type = "Internet" - } - route { - name = "mi-194-110-197-24-nexthop-internet" - address_prefix = "194.110.197.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-198-105-232-22-nexthop-internet" - address_prefix = "198.105.232.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-198-200-130-24-nexthop-internet" - address_prefix = "198.200.130.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-198-206-164-24-nexthop-internet" - address_prefix = "198.206.164.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-199-60-28-24-nexthop-internet" - address_prefix = "199.60.28.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-199-74-210-24-nexthop-internet" - address_prefix = "199.74.210.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-199-103-90-23-nexthop-internet" - address_prefix = "199.103.90.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-199-103-122-24-nexthop-internet" - address_prefix = "199.103.122.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-199-242-32-20-nexthop-internet" - address_prefix = "199.242.32.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-199-242-48-21-nexthop-internet" - address_prefix = "199.242.48.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-202-89-224-20-nexthop-internet" - address_prefix = "202.89.224.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-204-13-120-21-nexthop-internet" - address_prefix = "204.13.120.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-204-14-180-22-nexthop-internet" - address_prefix = "204.14.180.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-135-24-nexthop-internet" - address_prefix = "204.79.135.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-179-24-nexthop-internet" - address_prefix = "204.79.179.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-181-24-nexthop-internet" - address_prefix = "204.79.181.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-188-24-nexthop-internet" - address_prefix = "204.79.188.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-195-24-nexthop-internet" - address_prefix = "204.79.195.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-196-23-nexthop-internet" - address_prefix = "204.79.196.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-204-79-252-24-nexthop-internet" - address_prefix = "204.79.252.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-152-18-23-nexthop-internet" - address_prefix = "204.152.18.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-204-152-140-23-nexthop-internet" - address_prefix = "204.152.140.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-192-24-nexthop-internet" - address_prefix = "204.231.192.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-194-23-nexthop-internet" - address_prefix = "204.231.194.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-197-24-nexthop-internet" - address_prefix = "204.231.197.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-198-23-nexthop-internet" - address_prefix = "204.231.198.0/23" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-200-21-nexthop-internet" - address_prefix = "204.231.200.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-208-20-nexthop-internet" - address_prefix = "204.231.208.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-204-231-236-24-nexthop-internet" - address_prefix = "204.231.236.0/24" - next_hop_type = "Internet" - } - route { - name = "mi-205-174-224-20-nexthop-internet" - address_prefix = "205.174.224.0/20" - next_hop_type = "Internet" - } - route { - name = "mi-206-138-168-21-nexthop-internet" - address_prefix = "206.138.168.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-206-191-224-19-nexthop-internet" - address_prefix = "206.191.224.0/19" - next_hop_type = "Internet" - } - route { - name = "mi-207-46-16-nexthop-internet" - address_prefix = "207.46.0.0/16" - next_hop_type = "Internet" - } - route { - name = "mi-207-68-128-18-nexthop-internet" - address_prefix = "207.68.128.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-208-68-136-21-nexthop-internet" - address_prefix = "208.68.136.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-208-76-44-22-nexthop-internet" - address_prefix = "208.76.44.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-208-84-21-nexthop-internet" - address_prefix = "208.84.0.0/21" - next_hop_type = "Internet" - } - route { - name = "mi-209-240-192-19-nexthop-internet" - address_prefix = "209.240.192.0/19" - next_hop_type = "Internet" - } - route { - name = "mi-213-199-128-18-nexthop-internet" - address_prefix = "213.199.128.0/18" - next_hop_type = "Internet" - } - route { - name = "mi-216-32-180-22-nexthop-internet" - address_prefix = "216.32.180.0/22" - next_hop_type = "Internet" - } - route { - name = "mi-216-220-208-20-nexthop-internet" - address_prefix = "216.220.208.0/20" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-33-16-nexthop-internet" - address_prefix = "20.33.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-48-12-nexthop-internet" - address_prefix = "20.48.0.0/12" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-64-10-nexthop-internet" - address_prefix = "20.64.0.0/10" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-135-16-nexthop-internet" - address_prefix = "20.135.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-136-16-nexthop-internet" - address_prefix = "20.136.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-143-16-nexthop-internet" - address_prefix = "20.143.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-20-192-10-nexthop-internet" - address_prefix = "20.192.0.0/10" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-167-105-16-nexthop-internet" - address_prefix = "131.107.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-131-107-16-nexthop-internet" - address_prefix = "167.105.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-23-96-13-nexthop-internet" - address_prefix = "23.96.0.0/13" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-42-159-16-nexthop-internet" - address_prefix = "42.159.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-51-13-17-nexthop-internet" - address_prefix = "51.13.0.0/17" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-51-120-128-17-nexthop-internet" - address_prefix = "51.120.128.0/17" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-102-37-18-nexthop-internet" - address_prefix = "102.37.0.0/18" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-102-133-16-nexthop-internet" - address_prefix = "102.133.0.0/16" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-199-30-16-20-nexthop-internet" - address_prefix = "199.30.16.0/20" - next_hop_type = "Internet" - } - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-204-79-180-24-nexthop-internet" - address_prefix = "204.79.180.0/24" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage" - address_prefix = "Storage" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-SqlManagement" - address_prefix = "SqlManagement" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureMonitor" - address_prefix = "AzureMonitor" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-CorpNetSaw" - address_prefix = "CorpNetSaw" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-CorpNetPublic" - address_prefix = "CorpNetPublic" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureActiveDirectory" - address_prefix = "AzureActiveDirectory" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.westeurope" - address_prefix = "AzureCloud.westeurope" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.northeurope" - address_prefix = "AzureCloud.northeurope" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.westeurope" - address_prefix = "Storage.westeurope" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.northeurope" - address_prefix = "Storage.northeurope" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.francecentral" - address_prefix = "Storage.francecentral" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.francesouth" - address_prefix = "Storage.francesouth" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.westeurope" - address_prefix = "EventHub.westeurope" - next_hop_type = "Internet" - } - - route { - name = "Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.northeurope" - address_prefix = "EventHub.northeurope" - next_hop_type = "Internet" - } - - route { - address_prefix = "AzureCloud.westcentralus" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.westcentralus" - next_hop_type = "Internet" - } - - route { - address_prefix = "AzureCloud.westus2" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-AzureCloud.westus2" - next_hop_type = "Internet" - } - - route { - address_prefix = "Storage.westcentralus" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.westcentralus" - next_hop_type = "Internet" - } - - route { - address_prefix = "Storage.westus2" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Storage.westus2" - next_hop_type = "Internet" - } - - route { - address_prefix = "EventHub.westcentralus" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.westcentralus" - next_hop_type = "Internet" - } - - route { - address_prefix = "EventHub.westus2" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-EventHub.westus2" - next_hop_type = "Internet" - } - - route { - address_prefix = "Sql.westcentralus" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Sql.westcentralus" - next_hop_type = "Internet" - } - - route { - address_prefix = "Sql.westus2" - name = "Microsoft.Sql-managedInstances_UseOnly_mi-Sql.westus2" - next_hop_type = "Internet" - } -` - func TestAccMsSqlManagedInstance_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_mssql_managed_instance", "test") r := MsSqlManagedInstanceResource{} @@ -1024,7 +41,7 @@ func TestAccMsSqlManagedInstance_update(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.basic(data), + Config: r.basicZRS(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1038,7 +55,7 @@ func TestAccMsSqlManagedInstance_update(t *testing.T) { }, data.ImportStep("administrator_login_password"), { - Config: r.basic(data), + Config: r.basicZRS(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1068,7 +85,22 @@ func TestAccMsSqlManagedInstance_backupRedundancyLRS(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.storageType(data, "LRS"), + Config: r.storageType(data, "GZRS"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("administrator_login_password"), + }) +} + +func TestAccMsSqlManagedInstance_backupRedundancyGZRS(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mssql_managed_instance", "test") + r := MsSqlManagedInstanceResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.storageType(data, "GZRS"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -1219,14 +251,14 @@ func TestAccMsSqlManagedInstance_withMaintenanceConfig(t *testing.T) { } func (r MsSqlManagedInstanceResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ManagedInstanceID(state.ID) + id, err := commonids.ParseSqlManagedInstanceID(state.ID) if err != nil { return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstancesClient.Get(ctx, id.ResourceGroup, id.Name, "") + resp, err := client.MSSQLManagedInstance.ManagedInstancesClient.Get(ctx, *id, managedinstances.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving %s: %+v", id, err) @@ -1277,6 +309,50 @@ resource "azurerm_mssql_managed_instance" "test" { `, r.template(data, data.Locations.Primary), data.RandomInteger) } +func (r MsSqlManagedInstanceResource) basicZRS(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +provider "azurerm" { + features { + resource_group { + /* Due to the creation of unmanaged Microsoft.Network/networkIntentPolicies in this service, + prevent_deletion_if_contains_resources has been added here to allow the test resources to be + deleted until this can be properly investigated + */ + prevent_deletion_if_contains_resources = false + } + } +} + +resource "azurerm_mssql_managed_instance" "test" { + name = "acctestsqlserver%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + license_type = "BasePrice" + sku_name = "GP_Gen5" + storage_account_type = "ZRS" + storage_size_in_gb = 32 + subnet_id = azurerm_subnet.test.id + vcores = 4 + + administrator_login = "missadministrator" + administrator_login_password = "NCC-1701-D" + + depends_on = [ + azurerm_subnet_network_security_group_association.test, + azurerm_subnet_route_table_association.test, + ] + + tags = { + environment = "staging" + database = "test" + } +} +`, r.template(data, data.Locations.Primary), data.RandomInteger) +} + func (r MsSqlManagedInstanceResource) premium(data acceptance.TestData) string { return fmt.Sprintf(` %[1]s @@ -1437,6 +513,7 @@ resource "azurerm_mssql_managed_instance" "test" { proxy_override = "Proxy" public_data_endpoint_enabled = true sku_name = "GP_Gen5" + storage_account_type = "ZRS" storage_size_in_gb = 64 subnet_id = azurerm_subnet.test.id timezone_id = "Pacific Standard Time" @@ -1939,11 +1016,13 @@ resource "azurerm_route_table" "test" { next_hop_type = "VnetLocal" } - %[3]s - depends_on = [ azurerm_subnet.test, ] + + lifecycle { + ignore_changes = ["route"] + } } resource "azurerm_subnet_network_security_group_association" "test" { @@ -1955,7 +1034,7 @@ resource "azurerm_subnet_route_table_association" "test" { subnet_id = azurerm_subnet.test.id route_table_id = azurerm_route_table.test.id } - `, data.RandomInteger, location, managedInstanceStaticRoutes) + `, data.RandomInteger, location) } func (r MsSqlManagedInstanceResource) templateSecondary(data acceptance.TestData) string { @@ -2173,11 +1252,13 @@ resource "azurerm_route_table" "secondary" { next_hop_type = "VnetLocal" } - %[3]s - depends_on = [ azurerm_subnet.secondary, ] + + lifecycle { + ignore_changes = ["route"] + } } resource "azurerm_subnet_network_security_group_association" "secondary" { @@ -2189,7 +1270,7 @@ resource "azurerm_subnet_route_table_association" "secondary" { subnet_id = azurerm_subnet.secondary.id route_table_id = azurerm_route_table.secondary.id } - `, data.RandomInteger, data.Locations.Secondary, managedInstanceStaticRoutes) + `, data.RandomInteger, data.Locations.Secondary) } func (r MsSqlManagedInstanceResource) templateExtraSecondary(data acceptance.TestData) string { @@ -2407,11 +1488,13 @@ resource "azurerm_route_table" "secondary_2" { next_hop_type = "VnetLocal" } - %[3]s - depends_on = [ azurerm_subnet.secondary_2, ] + + lifecycle { + ignore_changes = ["route"] + } } resource "azurerm_subnet_network_security_group_association" "secondary_2" { @@ -2423,7 +1506,7 @@ resource "azurerm_subnet_route_table_association" "secondary_2" { subnet_id = azurerm_subnet.secondary_2.id route_table_id = azurerm_route_table.secondary_2.id } -`, data.RandomInteger, data.Locations.Secondary, managedInstanceStaticRoutes) +`, data.RandomInteger, data.Locations.Secondary) } func (r MsSqlManagedInstanceResource) withMaintenanceConfig(data acceptance.TestData) string { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource.go index 83f48035c1cb..0b16c60d4073 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource.go @@ -8,8 +8,11 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" @@ -116,30 +119,25 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyCreate(d *pluginsdk.Resource log.Printf("[INFO] preparing arguments for managed instance security alert policy creation.") - resourceGroupName := d.Get("resource_group_name").(string) - managedInstanceName := d.Get("managed_instance_name").(string) - alertPolicy := expandManagedServerSecurityAlertPolicy(d) - future, err := client.CreateOrUpdate(ctx, resourceGroupName, managedInstanceName, *alertPolicy) + managedInstanceId := commonids.NewSqlManagedInstanceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("managed_instance_name").(string)) + + err := client.CreateOrUpdateThenPoll(ctx, managedInstanceId, *alertPolicy) if err != nil { return fmt.Errorf("updating managed instance security alert policy: %v", err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creating of managed instance security alert policy (server %q, resource group %q): %+v", managedInstanceName, resourceGroupName, err) - } - - result, err := client.Get(ctx, resourceGroupName, managedInstanceName) + result, err := client.Get(ctx, managedInstanceId) if err != nil { - return fmt.Errorf("retrieving mssql manged instance security alert policy (managed instance %q, resource group %q): %+v", managedInstanceName, resourceGroupName, err) + return fmt.Errorf("retrieving %s: %+v", managedInstanceId, err) } - if result.Name == nil { - return fmt.Errorf("reading mssql manged instance security alert policy name (managed instance %q, resource group %q)", managedInstanceName, resourceGroupName) + if result.Model == nil || result.Model.Name == nil { + return fmt.Errorf("reading %s", managedInstanceId) } - id := parse.NewManagedInstancesSecurityAlertPolicyID(subscriptionId, resourceGroupName, managedInstanceName, *result.Name) + id := parse.NewManagedInstancesSecurityAlertPolicyID(subscriptionId, managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, *result.Model.Name) d.SetId(id.ID()) @@ -151,43 +149,47 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyUpdate(d *pluginsdk.Resource ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - resourceGroupName := d.Get("resource_group_name").(string) - instanceName := d.Get("managed_instance_name").(string) - id, err := parse.ManagedInstancesSecurityAlertPolicyID(d.Id()) if err != nil { return err } - existing, err := client.Get(ctx, resourceGroupName, instanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + existing, err := client.Get(ctx, managedInstanceId) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - props := existing.SecurityAlertsPolicyProperties - if props == nil { + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", *id) + } + + if existing.Model.Properties == nil { return fmt.Errorf("retrieving %s: `properties` was nil", *id) } + payload := existing.Model + if d.HasChange("disabled_alerts") { if v, ok := d.GetOk("disabled_alerts"); ok { disabledAlerts := make([]string, 0) for _, v := range v.(*pluginsdk.Set).List() { disabledAlerts = append(disabledAlerts, v.(string)) } - props.DisabledAlerts = &disabledAlerts + payload.Properties.DisabledAlerts = &disabledAlerts } else { - props.DisabledAlerts = nil + payload.Properties.DisabledAlerts = nil } } if d.HasChange("email_account_admins_enabled") { - props.EmailAccountAdmins = utils.Bool(d.Get("email_account_admins_enabled").(bool)) + payload.Properties.EmailAccountAdmins = utils.Bool(d.Get("email_account_admins_enabled").(bool)) } if d.HasChange("retention_days") { - props.RetentionDays = utils.Int32(int32(d.Get("retention_days").(int))) + payload.Properties.RetentionDays = pointer.To(int64(d.Get("retention_days").(int))) } if d.HasChange("email_addresses") { @@ -196,47 +198,43 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyUpdate(d *pluginsdk.Resource for _, v := range v.(*pluginsdk.Set).List() { emailAddresses = append(emailAddresses, v.(string)) } - props.EmailAddresses = &emailAddresses + payload.Properties.EmailAddresses = &emailAddresses } else { - props.EmailAddresses = nil + payload.Properties.EmailAddresses = nil } } if d.HasChange("enabled") { if d.Get("enabled").(bool) { - props.State = sql.SecurityAlertsPolicyStateEnabled + payload.Properties.State = managedserversecurityalertpolicies.SecurityAlertsPolicyStateEnabled } else { - props.State = sql.SecurityAlertsPolicyStateDisabled + payload.Properties.State = managedserversecurityalertpolicies.SecurityAlertsPolicyStateDisabled } } if d.HasChange("storage_account_access_key") { - props.StorageAccountAccessKey = utils.String(d.Get("storage_account_access_key").(string)) + payload.Properties.StorageAccountAccessKey = utils.String(d.Get("storage_account_access_key").(string)) } // StorageAccountAccessKey cannot be passed in if it is empty. The api returns this as empty so we need to nil it before sending it back to the api - if props.StorageAccountAccessKey != nil && *props.StorageAccountAccessKey == "" { - props.StorageAccountAccessKey = nil + if payload.Properties.StorageAccountAccessKey != nil && *payload.Properties.StorageAccountAccessKey == "" { + payload.Properties.StorageAccountAccessKey = nil } if d.HasChange("storage_endpoint") { - props.StorageEndpoint = utils.String(d.Get("storage_endpoint").(string)) + payload.Properties.StorageEndpoint = utils.String(d.Get("storage_endpoint").(string)) } // StorageEndpoint cannot be passed in if it is empty. The api returns this as empty so we need to nil it before sending it back to the api - if props.StorageEndpoint != nil && *props.StorageEndpoint == "" { - props.StorageEndpoint = nil + if payload.Properties.StorageEndpoint != nil && *payload.Properties.StorageEndpoint == "" { + payload.Properties.StorageEndpoint = nil } - future, err := client.CreateOrUpdate(ctx, resourceGroupName, instanceName, existing) + err = client.CreateOrUpdateThenPoll(ctx, managedInstanceId, *payload) if err != nil { return fmt.Errorf("updating managed instance security alert policy: %v", err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for updating of managed instance security alert policy (server %q, resource group %q): %+v", instanceName, resourceGroupName, err) - } - d.SetId(id.ID()) return resourceMsSqlManagedInstanceSecurityAlertPolicyRead(d, meta) @@ -254,9 +252,11 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyRead(d *pluginsdk.ResourceDa return err } - result, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + result, err := client.Get(ctx, managedInstanceId) if err != nil { - if utils.ResponseWasNotFound(result.Response) { + if response.WasNotFound(result.HttpResponse) { log.Printf("[WARN] managed instance security alert policy %v not found", id) d.SetId("") return nil @@ -268,45 +268,48 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyRead(d *pluginsdk.ResourceDa d.Set("resource_group_name", id.ResourceGroup) d.Set("managed_instance_name", id.ManagedInstanceName) - if props := result.SecurityAlertsPolicyProperties; props != nil { - d.Set("enabled", props.State == sql.SecurityAlertsPolicyStateEnabled) + if result.Model != nil { - if props.DisabledAlerts != nil { - disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{}) - for _, v := range *props.DisabledAlerts { - if v != "" { - disabledAlerts.Add(v) + if props := result.Model.Properties; props != nil { + d.Set("enabled", props.State == managedserversecurityalertpolicies.SecurityAlertsPolicyStateEnabled) + + if props.DisabledAlerts != nil { + disabledAlerts := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{}) + for _, v := range *props.DisabledAlerts { + if v != "" { + disabledAlerts.Add(v) + } } - } - d.Set("disabled_alerts", disabledAlerts) - } + d.Set("disabled_alerts", disabledAlerts) + } - if props.EmailAccountAdmins != nil { - d.Set("email_account_admins_enabled", props.EmailAccountAdmins) - } + if props.EmailAccountAdmins != nil { + d.Set("email_account_admins_enabled", props.EmailAccountAdmins) + } - if props.EmailAddresses != nil { - emailAddresses := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{}) - for _, v := range *props.EmailAddresses { - if v != "" { - emailAddresses.Add(v) + if props.EmailAddresses != nil { + emailAddresses := pluginsdk.NewSet(pluginsdk.HashString, []interface{}{}) + for _, v := range *props.EmailAddresses { + if v != "" { + emailAddresses.Add(v) + } } - } - d.Set("email_addresses", emailAddresses) - } + d.Set("email_addresses", emailAddresses) + } - if props.RetentionDays != nil { - d.Set("retention_days", int(*props.RetentionDays)) - } + if props.RetentionDays != nil { + d.Set("retention_days", int(*props.RetentionDays)) + } - if v, ok := d.GetOk("storage_account_access_key"); ok { - d.Set("storage_account_access_key", v) - } + if v, ok := d.GetOk("storage_account_access_key"); ok { + d.Set("storage_account_access_key", v) + } - if props.StorageEndpoint != nil { - d.Set("storage_endpoint", props.StorageEndpoint) + if props.StorageEndpoint != nil { + d.Set("storage_endpoint", props.StorageEndpoint) + } } } @@ -323,42 +326,40 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyDelete(d *pluginsdk.Resource return err } - disabledPolicy := sql.ManagedServerSecurityAlertPolicy{ - SecurityAlertsPolicyProperties: &sql.SecurityAlertsPolicyProperties{ - State: sql.SecurityAlertsPolicyStateDisabled, + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + disabledPolicy := managedserversecurityalertpolicies.ManagedServerSecurityAlertPolicy{ + Properties: &managedserversecurityalertpolicies.SecurityAlertsPolicyProperties{ + State: managedserversecurityalertpolicies.SecurityAlertsPolicyStateDisabled, }, } - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, disabledPolicy) + err = client.CreateOrUpdateThenPoll(ctx, managedInstanceId, disabledPolicy) if err != nil { return fmt.Errorf("updating managed instance security alert policy: %v", err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation/update of managed instance security alert policy (server %q, resource group %q): %+v", id.ManagedInstanceName, id.ResourceGroup, err) - } - - if _, err = client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName); err != nil { + if _, err = client.Get(ctx, managedInstanceId); err != nil { return fmt.Errorf("deleting managed instance security alert policy: %v", err) } return nil } -func expandManagedServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *sql.ManagedServerSecurityAlertPolicy { - state := sql.SecurityAlertsPolicyStateDisabled +func expandManagedServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *managedserversecurityalertpolicies.ManagedServerSecurityAlertPolicy { + state := managedserversecurityalertpolicies.SecurityAlertsPolicyStateDisabled if d.Get("enabled").(bool) { - state = sql.SecurityAlertsPolicyStateEnabled + state = managedserversecurityalertpolicies.SecurityAlertsPolicyStateEnabled } - policy := sql.ManagedServerSecurityAlertPolicy{ - SecurityAlertsPolicyProperties: &sql.SecurityAlertsPolicyProperties{ + policy := managedserversecurityalertpolicies.ManagedServerSecurityAlertPolicy{ + Properties: &managedserversecurityalertpolicies.SecurityAlertsPolicyProperties{ State: state, }, } - props := policy.SecurityAlertsPolicyProperties + props := policy.Properties if v, ok := d.GetOk("disabled_alerts"); ok { disabledAlerts := make([]string, 0) @@ -381,7 +382,7 @@ func expandManagedServerSecurityAlertPolicy(d *pluginsdk.ResourceData) *sql.Mana } if v, ok := d.GetOk("retention_days"); ok { - props.RetentionDays = utils.Int32(int32(v.(int))) + props.RetentionDays = utils.Int64(int64(v.(int))) } if v, ok := d.GetOk("storage_account_access_key"); ok { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource_test.go index b52b39de3052..9fb54141b0cd 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_security_alert_policy_resource_test.go @@ -8,6 +8,8 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" @@ -61,15 +63,17 @@ func (MsSqlManagedInstanceSecurityAlertPolicyResource) Exists(ctx context.Contex return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstanceServerSecurityAlertPoliciesClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + resp, err := client.MSSQLManagedInstance.ManagedInstanceServerSecurityAlertPoliciesClient.Get(ctx, instanceId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return nil, fmt.Errorf("SQL Managed Instance Security Alert Policy for server %q (Resource Group %q) does not exist", id.ManagedInstanceName, id.ResourceGroup) } return nil, fmt.Errorf("reading SQL Managed Instance Security Alert Policy for server %q (Resource Group %q): %v", id.ManagedInstanceName, id.ResourceGroup, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r MsSqlManagedInstanceSecurityAlertPolicyResource) basic(data acceptance.TestData) string { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource.go index a763472420a7..5ba21d6b501d 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource.go @@ -10,7 +10,10 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" keyVaultParser "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse" keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" @@ -68,7 +71,7 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionCreateUpdate(d *plugin ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - managedInstanceId, err := parse.ManagedInstanceID(d.Get("managed_instance_id").(string)) + managedInstanceId, err := commonids.ParseSqlManagedInstanceID(d.Get("managed_instance_id").(string)) if err != nil { return err } @@ -80,31 +83,31 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionCreateUpdate(d *plugin // because after the SQL server is created, we need to grant it permissions to AKV, so encryption protector can use those // keys are part of setting up TDE - var managedInstanceKey sql.ManagedInstanceKey + var managedInstanceKey managedinstancekeys.ManagedInstanceKey // Default values for Service Managed keys. Will update to AKV values if key_vault_key_id references a key. managedInstanceKeyName := "" - managedInstanceKeyType := sql.ServerKeyTypeServiceManaged + managedInstanceKeyType := managedinstancekeys.ServerKeyTypeServiceManaged keyVaultKeyId := strings.TrimSpace(d.Get("key_vault_key_id").(string)) // If it has content, then we assume it's a key vault key id if keyVaultKeyId != "" { // Update the server key type to AKV - managedInstanceKeyType = sql.ServerKeyTypeAzureKeyVault + managedInstanceKeyType = managedinstancekeys.ServerKeyTypeAzureKeyVault // Set the SQL Managed Instance Key properties - managedInstanceKeyProperties := sql.ManagedInstanceKeyProperties{ + managedInstanceKeyProperties := managedinstancekeys.ManagedInstanceKeyProperties{ ServerKeyType: managedInstanceKeyType, - URI: &keyVaultKeyId, + Uri: &keyVaultKeyId, AutoRotationEnabled: utils.Bool(d.Get("auto_rotation_enabled").(bool)), } - managedInstanceKey.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + managedInstanceKey.Properties = &managedInstanceKeyProperties // Set the encryption protector properties keyId, err := keyVaultParser.ParseNestedItemID(keyVaultKeyId) if err != nil { - return fmt.Errorf("Unable to parse key: %q: %+v", keyVaultKeyId, err) + return fmt.Errorf("unable to parse key: %q: %+v", keyVaultKeyId, err) } // Make sure it's a key, if not, throw an error @@ -115,7 +118,7 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionCreateUpdate(d *plugin // Extract the vault name from the keyvault base url idURL, err := url.ParseRequestURI(keyId.KeyVaultBaseUrl) if err != nil { - return fmt.Errorf("Unable to parse key vault hostname: %s", keyId.KeyVaultBaseUrl) + return fmt.Errorf("unable to parse key vault hostname: %s", keyId.KeyVaultBaseUrl) } hostParts := strings.Split(idURL.Host, ".") @@ -124,46 +127,44 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionCreateUpdate(d *plugin // Create the key path for the Encryption Protector. Format is: {vaultname}_{key}_{key_version} managedInstanceKeyName = fmt.Sprintf("%s_%s_%s", vaultName, keyName, keyVersion) } else { - return fmt.Errorf("Key vault key id must be a reference to a key, but got: %s", keyId.NestedItemType) + return fmt.Errorf("key vault key id must be a reference to a key, but got: %s", keyId.NestedItemType) } } + keyType := managedinstanceencryptionprotectors.ServerKeyTypeServiceManaged + if managedInstanceKeyType == managedinstancekeys.ServerKeyTypeAzureKeyVault { + keyType = managedinstanceencryptionprotectors.ServerKeyTypeAzureKeyVault + } // Service managed doesn't require a key name - encryptionProtectorProperties := sql.ManagedInstanceEncryptionProtectorProperties{ - ServerKeyType: managedInstanceKeyType, + encryptionProtectorProperties := managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtectorProperties{ + ServerKeyType: keyType, ServerKeyName: &managedInstanceKeyName, AutoRotationEnabled: utils.Bool(d.Get("auto_rotation_enabled").(bool)), } + managedInstanceKeyId := managedinstancekeys.NewManagedInstanceKeyID(managedInstanceId.SubscriptionId, managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, managedInstanceKeyName) // Only create a managed instance key if the properties have been set - if managedInstanceKey.ManagedInstanceKeyProperties != nil { + if managedInstanceKey.Properties != nil { // Create a key on the managed instance - futureServers, err := managedInstanceKeysClient.CreateOrUpdate(ctx, managedInstanceId.ResourceGroup, managedInstanceId.Name, managedInstanceKeyName, managedInstanceKey) + err = managedInstanceKeysClient.CreateOrUpdateThenPoll(ctx, managedInstanceKeyId, managedInstanceKey) if err != nil { return fmt.Errorf("creating/updating managed instance key for %s: %+v", managedInstanceId, err) } - if err = futureServers.WaitForCompletionRef(ctx, managedInstanceKeysClient.Client); err != nil { - return fmt.Errorf("waiting on update of %s: %+v", managedInstanceId, err) - } } - encryptionProtectorObject := sql.ManagedInstanceEncryptionProtector{ - ManagedInstanceEncryptionProtectorProperties: &encryptionProtectorProperties, + encryptionProtectorObject := managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtector{ + Properties: &encryptionProtectorProperties, } // Encryption protector always uses "current" for the name - id := parse.NewManagedInstanceEncryptionProtectorID(managedInstanceId.SubscriptionId, managedInstanceId.ResourceGroup, managedInstanceId.Name, "current") + id := parse.NewManagedInstanceEncryptionProtectorID(managedInstanceId.SubscriptionId, managedInstanceId.ResourceGroupName, managedInstanceId.ManagedInstanceName, "current") - futureEncryptionProtector, err := encryptionProtectorClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, encryptionProtectorObject) + err = encryptionProtectorClient.CreateOrUpdateThenPoll(ctx, *managedInstanceId, encryptionProtectorObject) if err != nil { return fmt.Errorf("creating/updating %s: %+v", id, err) } - if err = futureEncryptionProtector.WaitForCompletionRef(ctx, encryptionProtectorClient.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) - } - d.SetId(id.ID()) return resourceMsSqlManagedInstanceTransparentDataEncryptionRead(d, meta) @@ -180,43 +181,47 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionRead(d *pluginsdk.Reso return err } - resp, err := encryptionProtectorClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + resp, err := encryptionProtectorClient.Get(ctx, managedInstanceId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("making Read request for %s: %v", id, err) } - managedInstanceId := parse.NewManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) d.Set("managed_instance_id", managedInstanceId.ID()) - log.Printf("[INFO] Encryption protector key type is %s", resp.ManagedInstanceEncryptionProtectorProperties.ServerKeyType) + if resp.Model != nil && resp.Model.Properties != nil { - keyVaultKeyId := "" - autoRotationEnabled := false + log.Printf("[INFO] Encryption protector key type is %s", resp.Model.Properties.ServerKeyType) - // Only set the key type if it's an AKV key. For service managed, we can omit the setting the key_vault_key_id - if resp.ManagedInstanceEncryptionProtectorProperties != nil && resp.ManagedInstanceEncryptionProtectorProperties.ServerKeyType == sql.ServerKeyTypeAzureKeyVault { - log.Printf("[INFO] Setting Key Vault URI to %s", *resp.ManagedInstanceEncryptionProtectorProperties.URI) + keyVaultKeyId := "" + autoRotationEnabled := false - keyVaultKeyId = *resp.ManagedInstanceEncryptionProtectorProperties.URI + // Only set the key type if it's an AKV key. For service managed, we can omit the setting the key_vault_key_id + if resp.Model.Properties.ServerKeyType == managedinstanceencryptionprotectors.ServerKeyTypeAzureKeyVault { + if resp.Model.Properties.Uri != nil { + log.Printf("[INFO] Setting Key Vault URI to %s", *resp.Model.Properties.Uri) + keyVaultKeyId = *resp.Model.Properties.Uri + } - // autoRotation is only for AKV keys - if resp.ManagedInstanceEncryptionProtectorProperties.AutoRotationEnabled != nil { - autoRotationEnabled = *resp.ManagedInstanceEncryptionProtectorProperties.AutoRotationEnabled + // autoRotation is only for AKV keys + if resp.Model.Properties.AutoRotationEnabled != nil { + autoRotationEnabled = *resp.Model.Properties.AutoRotationEnabled + } } - } - if err := d.Set("key_vault_key_id", keyVaultKeyId); err != nil { - return fmt.Errorf("setting `key_vault_key_id`: %+v", err) - } + if err := d.Set("key_vault_key_id", keyVaultKeyId); err != nil { + return fmt.Errorf("setting `key_vault_key_id`: %+v", err) + } - if err := d.Set("auto_rotation_enabled", autoRotationEnabled); err != nil { - return fmt.Errorf("setting `auto_rotation_enabled`: %+v", err) + if err := d.Set("auto_rotation_enabled", autoRotationEnabled); err != nil { + return fmt.Errorf("setting `auto_rotation_enabled`: %+v", err) + } } - return nil } @@ -234,24 +239,23 @@ func resourceMsSqlManagedInstanceTransparentDataEncryptionDelete(d *pluginsdk.Re return err } + managedInstanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + managedInstanceKeyName := "" // Service managed doesn't require a key name - encryptionProtector := sql.ManagedInstanceEncryptionProtector{ - ManagedInstanceEncryptionProtectorProperties: &sql.ManagedInstanceEncryptionProtectorProperties{ - ServerKeyType: sql.ServerKeyTypeServiceManaged, + encryptionProtector := managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtector{ + + Properties: &managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtectorProperties{ + ServerKeyType: managedinstanceencryptionprotectors.ServerKeyTypeServiceManaged, ServerKeyName: &managedInstanceKeyName, }, } - futureEncryptionProtector, err := encryptionProtectorClient.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, encryptionProtector) + err = encryptionProtectorClient.CreateOrUpdateThenPoll(ctx, managedInstanceId, encryptionProtector) if err != nil { return fmt.Errorf("creating/updating %s: %+v", id, err) } - if err = futureEncryptionProtector.WaitForCompletionRef(ctx, encryptionProtectorClient.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) - } - return nil } diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource_test.go index 8bbef5aa5564..f06acf247533 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_transparent_data_encryption_resource_test.go @@ -8,6 +8,8 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" @@ -109,16 +111,17 @@ func (MsSqlManagedInstanceTransparentDataEncryptionResource) Exists(ctx context. return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstanceEncryptionProtectorClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + resp, err := client.MSSQLManagedInstance.ManagedInstanceEncryptionProtectorClient.Get(ctx, instanceId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return nil, fmt.Errorf("Encryption protector for managed instance %q (Resource Group %q) does not exist", id.ManagedInstanceName, id.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { + return nil, fmt.Errorf("encryption protector for managed instance %q (Resource Group %q) does not exist", id.ManagedInstanceName, id.ResourceGroup) } return nil, fmt.Errorf("reading Encryption Protector for managed instance %q (Resource Group %q): %v", id.ManagedInstanceName, id.ResourceGroup, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r MsSqlManagedInstanceTransparentDataEncryptionResource) keyVaultSystemAssignedIdentity(data acceptance.TestData) string { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource.go index eb7d0d5076db..e06db353b92b 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource.go @@ -8,7 +8,9 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate" @@ -104,23 +106,23 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentCreate(d *pluginsdk.Reso ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - instanceId, err := parse.ManagedInstanceID(d.Get("managed_instance_id").(string)) + instanceId, err := commonids.ParseSqlManagedInstanceID(d.Get("managed_instance_id").(string)) if err != nil { return err } - id := parse.NewManagedInstanceVulnerabilityAssessmentID(instanceId.SubscriptionId, instanceId.ResourceGroup, instanceId.Name, "default") + id := parse.NewManagedInstanceVulnerabilityAssessmentID(instanceId.SubscriptionId, instanceId.ResourceGroupName, instanceId.ManagedInstanceName, "default") - vulnerabilityAssessment := sql.ManagedInstanceVulnerabilityAssessment{ - ManagedInstanceVulnerabilityAssessmentProperties: &sql.ManagedInstanceVulnerabilityAssessmentProperties{ - StorageContainerPath: utils.String(d.Get("storage_container_path").(string)), + vulnerabilityAssessment := managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessment{ + Properties: &managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessmentProperties{ + StorageContainerPath: d.Get("storage_container_path").(string), StorageAccountAccessKey: utils.String(d.Get("storage_account_access_key").(string)), StorageContainerSasKey: utils.String(d.Get("storage_container_sas_key").(string)), RecurringScans: expandRecurringScans(d), }, } - if _, err = client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, vulnerabilityAssessment); err != nil { + if _, err = client.CreateOrUpdate(ctx, *instanceId, vulnerabilityAssessment); err != nil { return fmt.Errorf("updating %s: %v", id.ID(), err) } @@ -139,16 +141,18 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentUpdate(d *pluginsdk.Reso return err } - vulnerabilityAssessment := sql.ManagedInstanceVulnerabilityAssessment{ - ManagedInstanceVulnerabilityAssessmentProperties: &sql.ManagedInstanceVulnerabilityAssessmentProperties{ - StorageContainerPath: utils.String(d.Get("storage_container_path").(string)), + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + vulnerabilityAssessment := managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessment{ + Properties: &managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessmentProperties{ + StorageContainerPath: d.Get("storage_container_path").(string), StorageAccountAccessKey: utils.String(d.Get("storage_account_access_key").(string)), StorageContainerSasKey: utils.String(d.Get("storage_container_sas_key").(string)), RecurringScans: expandRecurringScans(d), }, } - if _, err = client.CreateOrUpdate(ctx, id.ResourceGroup, id.ManagedInstanceName, vulnerabilityAssessment); err != nil { + if _, err = client.CreateOrUpdate(ctx, instanceId, vulnerabilityAssessment); err != nil { return fmt.Errorf("updating %s: %v", id.ID(), err) } @@ -167,9 +171,12 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentRead(d *pluginsdk.Resour return err } - result, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + d.Set("managed_instance_id", instanceId.ID()) + + result, err := client.Get(ctx, instanceId) if err != nil { - if utils.ResponseWasNotFound(result.Response) { + if response.WasNotFound(result.HttpResponse) { log.Printf("[WARN] %s not found", id.ID()) d.SetId("") return nil @@ -178,18 +185,17 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentRead(d *pluginsdk.Resour return fmt.Errorf("making read request: %+v", err) } - if props := result.ManagedInstanceVulnerabilityAssessmentProperties; props != nil { - d.Set("storage_container_path", props.StorageContainerPath) + if result.Model != nil { + if props := result.Model.Properties; props != nil { + d.Set("storage_container_path", props.StorageContainerPath) - if props.RecurringScans != nil { - if err := d.Set("recurring_scans", flattenRecurringScans(props.RecurringScans)); err != nil { - return fmt.Errorf("setting `recurring_scans`: %+v", err) + if props.RecurringScans != nil { + if err := d.Set("recurring_scans", flattenRecurringScans(props.RecurringScans)); err != nil { + return fmt.Errorf("setting `recurring_scans`: %+v", err) + } } } } - - d.Set("managed_instance_id", parse.NewManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName).ID()) - return nil } @@ -203,7 +209,9 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentDelete(d *pluginsdk.Reso return err } - _, err = client.Delete(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + _, err = client.Delete(ctx, instanceId) if err != nil { return fmt.Errorf("deleting Managed Instance Vulnerability Assessment %s: %+v", id.ID(), err) } @@ -211,8 +219,8 @@ func resourceMsSqlManagedInstanceVulnerabilityAssessmentDelete(d *pluginsdk.Reso return nil } -func expandRecurringScans(d *pluginsdk.ResourceData) *sql.VulnerabilityAssessmentRecurringScansProperties { - props := sql.VulnerabilityAssessmentRecurringScansProperties{} +func expandRecurringScans(d *pluginsdk.ResourceData) *managedinstancevulnerabilityassessments.VulnerabilityAssessmentRecurringScansProperties { + props := managedinstancevulnerabilityassessments.VulnerabilityAssessmentRecurringScansProperties{} vs := d.Get("recurring_scans").([]interface{}) if len(vs) == 0 { @@ -240,7 +248,7 @@ func expandRecurringScans(d *pluginsdk.ResourceData) *sql.VulnerabilityAssessmen return &props } -func flattenRecurringScans(props *sql.VulnerabilityAssessmentRecurringScansProperties) []interface{} { +func flattenRecurringScans(props *managedinstancevulnerabilityassessments.VulnerabilityAssessmentRecurringScansProperties) []interface{} { result := make(map[string]interface{}) if enabled := props.IsEnabled; enabled != nil { diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource_test.go index fc05a49584cb..736da149d079 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_instance_vulnerability_assessment_resource_test.go @@ -8,6 +8,8 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" @@ -61,16 +63,18 @@ func (MsSqlManagedInstanceVulnerabilityAssessmentResource) Exists(ctx context.Co return nil, err } - resp, err := client.MSSQLManagedInstance.ManagedInstanceVulnerabilityAssessmentsClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName) + instanceId := commonids.NewSqlManagedInstanceID(id.SubscriptionId, id.ResourceGroup, id.ManagedInstanceName) + + resp, err := client.MSSQLManagedInstance.ManagedInstanceVulnerabilityAssessmentsClient.Get(ctx, instanceId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return nil, fmt.Errorf("%s does not exist", id.ID()) } return nil, fmt.Errorf("reading %s: %v", id.ID(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r MsSqlManagedInstanceVulnerabilityAssessmentResource) basic(data acceptance.TestData) string { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/README.md new file mode 100644 index 000000000000..4f66bd83dfaa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/README.md @@ -0,0 +1,106 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups` Documentation + +The `instancefailovergroups` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups" +``` + + +### Client Initialization + +```go +client := instancefailovergroups.NewInstanceFailoverGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `InstanceFailoverGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewInstanceFailoverGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue", "instanceFailoverGroupValue") + +payload := instancefailovergroups.InstanceFailoverGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `InstanceFailoverGroupsClient.Delete` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewInstanceFailoverGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue", "instanceFailoverGroupValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `InstanceFailoverGroupsClient.Failover` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewInstanceFailoverGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue", "instanceFailoverGroupValue") + +if err := client.FailoverThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `InstanceFailoverGroupsClient.ForceFailoverAllowDataLoss` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewInstanceFailoverGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue", "instanceFailoverGroupValue") + +if err := client.ForceFailoverAllowDataLossThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `InstanceFailoverGroupsClient.Get` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewInstanceFailoverGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue", "instanceFailoverGroupValue") + +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: `InstanceFailoverGroupsClient.ListByLocation` + +```go +ctx := context.TODO() +id := instancefailovergroups.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/client.go new file mode 100644 index 000000000000..77237fd2c0a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/client.go @@ -0,0 +1,26 @@ +package instancefailovergroups + +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 InstanceFailoverGroupsClient struct { + Client *resourcemanager.Client +} + +func NewInstanceFailoverGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*InstanceFailoverGroupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "instancefailovergroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating InstanceFailoverGroupsClient: %+v", err) + } + + return &InstanceFailoverGroupsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/constants.go new file mode 100644 index 000000000000..bada7a8e899e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/constants.go @@ -0,0 +1,174 @@ +package instancefailovergroups + +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 InstanceFailoverGroupReplicationRole string + +const ( + InstanceFailoverGroupReplicationRolePrimary InstanceFailoverGroupReplicationRole = "Primary" + InstanceFailoverGroupReplicationRoleSecondary InstanceFailoverGroupReplicationRole = "Secondary" +) + +func PossibleValuesForInstanceFailoverGroupReplicationRole() []string { + return []string{ + string(InstanceFailoverGroupReplicationRolePrimary), + string(InstanceFailoverGroupReplicationRoleSecondary), + } +} + +func (s *InstanceFailoverGroupReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstanceFailoverGroupReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstanceFailoverGroupReplicationRole(input string) (*InstanceFailoverGroupReplicationRole, error) { + vals := map[string]InstanceFailoverGroupReplicationRole{ + "primary": InstanceFailoverGroupReplicationRolePrimary, + "secondary": InstanceFailoverGroupReplicationRoleSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstanceFailoverGroupReplicationRole(input) + return &out, nil +} + +type ReadOnlyEndpointFailoverPolicy string + +const ( + ReadOnlyEndpointFailoverPolicyDisabled ReadOnlyEndpointFailoverPolicy = "Disabled" + ReadOnlyEndpointFailoverPolicyEnabled ReadOnlyEndpointFailoverPolicy = "Enabled" +) + +func PossibleValuesForReadOnlyEndpointFailoverPolicy() []string { + return []string{ + string(ReadOnlyEndpointFailoverPolicyDisabled), + string(ReadOnlyEndpointFailoverPolicyEnabled), + } +} + +func (s *ReadOnlyEndpointFailoverPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReadOnlyEndpointFailoverPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReadOnlyEndpointFailoverPolicy(input string) (*ReadOnlyEndpointFailoverPolicy, error) { + vals := map[string]ReadOnlyEndpointFailoverPolicy{ + "disabled": ReadOnlyEndpointFailoverPolicyDisabled, + "enabled": ReadOnlyEndpointFailoverPolicyEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReadOnlyEndpointFailoverPolicy(input) + return &out, nil +} + +type ReadWriteEndpointFailoverPolicy string + +const ( + ReadWriteEndpointFailoverPolicyAutomatic ReadWriteEndpointFailoverPolicy = "Automatic" + ReadWriteEndpointFailoverPolicyManual ReadWriteEndpointFailoverPolicy = "Manual" +) + +func PossibleValuesForReadWriteEndpointFailoverPolicy() []string { + return []string{ + string(ReadWriteEndpointFailoverPolicyAutomatic), + string(ReadWriteEndpointFailoverPolicyManual), + } +} + +func (s *ReadWriteEndpointFailoverPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReadWriteEndpointFailoverPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReadWriteEndpointFailoverPolicy(input string) (*ReadWriteEndpointFailoverPolicy, error) { + vals := map[string]ReadWriteEndpointFailoverPolicy{ + "automatic": ReadWriteEndpointFailoverPolicyAutomatic, + "manual": ReadWriteEndpointFailoverPolicyManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReadWriteEndpointFailoverPolicy(input) + return &out, nil +} + +type SecondaryInstanceType string + +const ( + SecondaryInstanceTypeGeo SecondaryInstanceType = "Geo" + SecondaryInstanceTypeStandby SecondaryInstanceType = "Standby" +) + +func PossibleValuesForSecondaryInstanceType() []string { + return []string{ + string(SecondaryInstanceTypeGeo), + string(SecondaryInstanceTypeStandby), + } +} + +func (s *SecondaryInstanceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecondaryInstanceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecondaryInstanceType(input string) (*SecondaryInstanceType, error) { + vals := map[string]SecondaryInstanceType{ + "geo": SecondaryInstanceTypeGeo, + "standby": SecondaryInstanceTypeStandby, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecondaryInstanceType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_instancefailovergroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_instancefailovergroup.go new file mode 100644 index 000000000000..56d3645eed9a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_instancefailovergroup.go @@ -0,0 +1,139 @@ +package instancefailovergroups + +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(&InstanceFailoverGroupId{}) +} + +var _ resourceids.ResourceId = &InstanceFailoverGroupId{} + +// InstanceFailoverGroupId is a struct representing the Resource ID for a Instance Failover Group +type InstanceFailoverGroupId struct { + SubscriptionId string + ResourceGroupName string + LocationName string + InstanceFailoverGroupName string +} + +// NewInstanceFailoverGroupID returns a new InstanceFailoverGroupId struct +func NewInstanceFailoverGroupID(subscriptionId string, resourceGroupName string, locationName string, instanceFailoverGroupName string) InstanceFailoverGroupId { + return InstanceFailoverGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + InstanceFailoverGroupName: instanceFailoverGroupName, + } +} + +// ParseInstanceFailoverGroupID parses 'input' into a InstanceFailoverGroupId +func ParseInstanceFailoverGroupID(input string) (*InstanceFailoverGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceFailoverGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceFailoverGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceFailoverGroupIDInsensitively parses 'input' case-insensitively into a InstanceFailoverGroupId +// note: this method should only be used for API response data and not user input +func ParseInstanceFailoverGroupIDInsensitively(input string) (*InstanceFailoverGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceFailoverGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceFailoverGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceFailoverGroupId) 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.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.InstanceFailoverGroupName, ok = input.Parsed["instanceFailoverGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceFailoverGroupName", input) + } + + return nil +} + +// ValidateInstanceFailoverGroupID checks that 'input' can be parsed as a Instance Failover Group ID +func ValidateInstanceFailoverGroupID(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 := ParseInstanceFailoverGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Failover Group ID +func (id InstanceFailoverGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Sql/locations/%s/instanceFailoverGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName, id.InstanceFailoverGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Failover Group ID +func (id InstanceFailoverGroupId) 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("staticMicrosoftSql", "Microsoft.Sql", "Microsoft.Sql"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticInstanceFailoverGroups", "instanceFailoverGroups", "instanceFailoverGroups"), + resourceids.UserSpecifiedSegment("instanceFailoverGroupName", "instanceFailoverGroupValue"), + } +} + +// String returns a human-readable description of this Instance Failover Group ID +func (id InstanceFailoverGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Instance Failover Group Name: %q", id.InstanceFailoverGroupName), + } + return fmt.Sprintf("Instance Failover Group (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_providerlocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_providerlocation.go new file mode 100644 index 000000000000..433544172373 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/id_providerlocation.go @@ -0,0 +1,130 @@ +package instancefailovergroups + +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(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) 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.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(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 := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Sql/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) 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("staticMicrosoftSql", "Microsoft.Sql", "Microsoft.Sql"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_createorupdate.go new file mode 100644 index 000000000000..2c3e879c19e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_createorupdate.go @@ -0,0 +1,76 @@ +package instancefailovergroups + +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 *InstanceFailoverGroup +} + +// CreateOrUpdate ... +func (c InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, id InstanceFailoverGroupId, input InstanceFailoverGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 InstanceFailoverGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id InstanceFailoverGroupId, input InstanceFailoverGroup) 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/sql/2023-08-01-preview/instancefailovergroups/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_delete.go new file mode 100644 index 000000000000..16c9e12489a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_delete.go @@ -0,0 +1,71 @@ +package instancefailovergroups + +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 InstanceFailoverGroupsClient) Delete(ctx context.Context, id InstanceFailoverGroupId) (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 InstanceFailoverGroupsClient) DeleteThenPoll(ctx context.Context, id InstanceFailoverGroupId) 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/sql/2023-08-01-preview/instancefailovergroups/method_failover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_failover.go new file mode 100644 index 000000000000..33f750aa0d77 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_failover.go @@ -0,0 +1,71 @@ +package instancefailovergroups + +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 FailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *InstanceFailoverGroup +} + +// Failover ... +func (c InstanceFailoverGroupsClient) Failover(ctx context.Context, id InstanceFailoverGroupId) (result FailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failover", 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 +} + +// FailoverThenPoll performs Failover then polls until it's completed +func (c InstanceFailoverGroupsClient) FailoverThenPoll(ctx context.Context, id InstanceFailoverGroupId) error { + result, err := c.Failover(ctx, id) + if err != nil { + return fmt.Errorf("performing Failover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Failover: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_forcefailoverallowdataloss.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_forcefailoverallowdataloss.go new file mode 100644 index 000000000000..9634e7ef7e4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_forcefailoverallowdataloss.go @@ -0,0 +1,71 @@ +package instancefailovergroups + +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 ForceFailoverAllowDataLossOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *InstanceFailoverGroup +} + +// ForceFailoverAllowDataLoss ... +func (c InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, id InstanceFailoverGroupId) (result ForceFailoverAllowDataLossOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/forceFailoverAllowDataLoss", 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 +} + +// ForceFailoverAllowDataLossThenPoll performs ForceFailoverAllowDataLoss then polls until it's completed +func (c InstanceFailoverGroupsClient) ForceFailoverAllowDataLossThenPoll(ctx context.Context, id InstanceFailoverGroupId) error { + result, err := c.ForceFailoverAllowDataLoss(ctx, id) + if err != nil { + return fmt.Errorf("performing ForceFailoverAllowDataLoss: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ForceFailoverAllowDataLoss: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_get.go new file mode 100644 index 000000000000..1254e8ce94bd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_get.go @@ -0,0 +1,54 @@ +package instancefailovergroups + +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 *InstanceFailoverGroup +} + +// Get ... +func (c InstanceFailoverGroupsClient) Get(ctx context.Context, id InstanceFailoverGroupId) (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 InstanceFailoverGroup + 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/sql/2023-08-01-preview/instancefailovergroups/method_listbylocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_listbylocation.go new file mode 100644 index 000000000000..b5ab352fd086 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/method_listbylocation.go @@ -0,0 +1,105 @@ +package instancefailovergroups + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InstanceFailoverGroup +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []InstanceFailoverGroup +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c InstanceFailoverGroupsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/instanceFailoverGroups", 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 *[]InstanceFailoverGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c InstanceFailoverGroupsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, InstanceFailoverGroupOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c InstanceFailoverGroupsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate InstanceFailoverGroupOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]InstanceFailoverGroup, 0) + + resp, err := c.ListByLocation(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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroup.go new file mode 100644 index 000000000000..d143e10f5b1c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroup.go @@ -0,0 +1,11 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceFailoverGroup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InstanceFailoverGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupproperties.go new file mode 100644 index 000000000000..856450141870 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupproperties.go @@ -0,0 +1,14 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceFailoverGroupProperties struct { + ManagedInstancePairs []ManagedInstancePairInfo `json:"managedInstancePairs"` + PartnerRegions []PartnerRegionInfo `json:"partnerRegions"` + ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + ReadWriteEndpoint InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint"` + ReplicationRole *InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + ReplicationState *string `json:"replicationState,omitempty"` + SecondaryType *SecondaryInstanceType `json:"secondaryType,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadonlyendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadonlyendpoint.go new file mode 100644 index 000000000000..af9aae49c73b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadonlyendpoint.go @@ -0,0 +1,8 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceFailoverGroupReadOnlyEndpoint struct { + FailoverPolicy *ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadwriteendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadwriteendpoint.go new file mode 100644 index 000000000000..6470ba23b9e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_instancefailovergroupreadwriteendpoint.go @@ -0,0 +1,9 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceFailoverGroupReadWriteEndpoint struct { + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy"` + FailoverWithDataLossGracePeriodMinutes *int64 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_managedinstancepairinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_managedinstancepairinfo.go new file mode 100644 index 000000000000..2e3aef9ff300 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_managedinstancepairinfo.go @@ -0,0 +1,9 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstancePairInfo struct { + PartnerManagedInstanceId *string `json:"partnerManagedInstanceId,omitempty"` + PrimaryManagedInstanceId *string `json:"primaryManagedInstanceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_partnerregioninfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_partnerregioninfo.go new file mode 100644 index 000000000000..948ef2924592 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/model_partnerregioninfo.go @@ -0,0 +1,9 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartnerRegionInfo struct { + Location *string `json:"location,omitempty"` + ReplicationRole *InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/predicates.go new file mode 100644 index 000000000000..bc1705b3dc46 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/predicates.go @@ -0,0 +1,27 @@ +package instancefailovergroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceFailoverGroupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p InstanceFailoverGroupOperationPredicate) Matches(input InstanceFailoverGroup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/version.go new file mode 100644 index 000000000000..ea6b1f62688a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups/version.go @@ -0,0 +1,12 @@ +package instancefailovergroups + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/instancefailovergroups/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/README.md new file mode 100644 index 000000000000..3c87388b7c0b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/README.md @@ -0,0 +1,88 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies` Documentation + +The `managedbackupshorttermretentionpolicies` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies" +``` + + +### Client Initialization + +```go +client := managedbackupshorttermretentionpolicies.NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedBackupShortTermRetentionPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedBackupShortTermRetentionPoliciesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +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: `ManagedBackupShortTermRetentionPoliciesClient.ListByDatabase` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +// alternatively `client.ListByDatabase(ctx, id)` can be used to do batched pagination +items, err := client.ListByDatabaseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedBackupShortTermRetentionPoliciesClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/client.go new file mode 100644 index 000000000000..d012d8b6e323 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/client.go @@ -0,0 +1,26 @@ +package managedbackupshorttermretentionpolicies + +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 ManagedBackupShortTermRetentionPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedBackupShortTermRetentionPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedbackupshorttermretentionpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedBackupShortTermRetentionPoliciesClient: %+v", err) + } + + return &ManagedBackupShortTermRetentionPoliciesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_createorupdate.go new file mode 100644 index 000000000000..e7fb1a0180ed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedbackupshorttermretentionpolicies + +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/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 *ManagedBackupShortTermRetentionPolicy +} + +// CreateOrUpdate ... +func (c ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedBackupShortTermRetentionPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/backupShortTermRetentionPolicies/default", 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 ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedBackupShortTermRetentionPolicy) 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/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_get.go new file mode 100644 index 000000000000..1c274cb2a2b5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_get.go @@ -0,0 +1,56 @@ +package managedbackupshorttermretentionpolicies + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedBackupShortTermRetentionPolicy +} + +// Get ... +func (c ManagedBackupShortTermRetentionPoliciesClient) Get(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupShortTermRetentionPolicies/default", 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 ManagedBackupShortTermRetentionPolicy + 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/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_listbydatabase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_listbydatabase.go new file mode 100644 index 000000000000..abd1880b4639 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_listbydatabase.go @@ -0,0 +1,106 @@ +package managedbackupshorttermretentionpolicies + +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 ListByDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedBackupShortTermRetentionPolicy +} + +type ListByDatabaseCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedBackupShortTermRetentionPolicy +} + +type ListByDatabaseCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByDatabaseCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByDatabase ... +func (c ManagedBackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (result ListByDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByDatabaseCustomPager{}, + Path: fmt.Sprintf("%s/backupShortTermRetentionPolicies", 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 *[]ManagedBackupShortTermRetentionPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByDatabaseComplete retrieves all the results into a single object +func (c ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (ListByDatabaseCompleteResult, error) { + return c.ListByDatabaseCompleteMatchingPredicate(ctx, id, ManagedBackupShortTermRetentionPolicyOperationPredicate{}) +} + +// ListByDatabaseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, predicate ManagedBackupShortTermRetentionPolicyOperationPredicate) (result ListByDatabaseCompleteResult, err error) { + items := make([]ManagedBackupShortTermRetentionPolicy, 0) + + resp, err := c.ListByDatabase(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 = ListByDatabaseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_update.go new file mode 100644 index 000000000000..fa0a7cba6f89 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/method_update.go @@ -0,0 +1,76 @@ +package managedbackupshorttermretentionpolicies + +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/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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedBackupShortTermRetentionPolicy +} + +// Update ... +func (c ManagedBackupShortTermRetentionPoliciesClient) Update(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedBackupShortTermRetentionPolicy) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/backupShortTermRetentionPolicies/default", 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ManagedBackupShortTermRetentionPoliciesClient) UpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedBackupShortTermRetentionPolicy) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicy.go new file mode 100644 index 000000000000..9550c29a4e0b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicy.go @@ -0,0 +1,11 @@ +package managedbackupshorttermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedBackupShortTermRetentionPolicy struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedBackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicyproperties.go new file mode 100644 index 000000000000..c7e8ce4271d5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/model_managedbackupshorttermretentionpolicyproperties.go @@ -0,0 +1,8 @@ +package managedbackupshorttermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedBackupShortTermRetentionPolicyProperties struct { + RetentionDays *int64 `json:"retentionDays,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/predicates.go new file mode 100644 index 000000000000..fb75828a8757 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/predicates.go @@ -0,0 +1,27 @@ +package managedbackupshorttermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedBackupShortTermRetentionPolicyOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedBackupShortTermRetentionPolicyOperationPredicate) Matches(input ManagedBackupShortTermRetentionPolicy) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/version.go new file mode 100644 index 000000000000..14b1ba138557 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies/version.go @@ -0,0 +1,12 @@ +package managedbackupshorttermretentionpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedbackupshorttermretentionpolicies/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/README.md new file mode 100644 index 000000000000..ff8a9366c9bc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/README.md @@ -0,0 +1,185 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases` Documentation + +The `manageddatabases` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/manageddatabases" +``` + + +### Client Initialization + +```go +client := manageddatabases.NewManagedDatabasesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedDatabasesClient.CancelMove` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.ManagedDatabaseMoveDefinition{ + // ... +} + + +if err := client.CancelMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.CompleteMove` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.ManagedDatabaseMoveDefinition{ + // ... +} + + +if err := client.CompleteMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.CompleteRestore` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.CompleteDatabaseRestoreDefinition{ + // ... +} + + +if err := client.CompleteRestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.ManagedDatabase{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +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: `ManagedDatabasesClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedDatabasesClient.ListInaccessibleByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListInaccessibleByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListInaccessibleByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedDatabasesClient.StartMove` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.ManagedDatabaseStartMoveDefinition{ + // ... +} + + +if err := client.StartMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedDatabasesClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := manageddatabases.ManagedDatabaseUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/client.go new file mode 100644 index 000000000000..d7286c73b101 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/client.go @@ -0,0 +1,26 @@ +package manageddatabases + +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 ManagedDatabasesClient struct { + Client *resourcemanager.Client +} + +func NewManagedDatabasesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedDatabasesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "manageddatabases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedDatabasesClient: %+v", err) + } + + return &ManagedDatabasesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/constants.go new file mode 100644 index 000000000000..9973e086db9b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/constants.go @@ -0,0 +1,213 @@ +package manageddatabases + +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 CatalogCollationType string + +const ( + CatalogCollationTypeDATABASEDEFAULT CatalogCollationType = "DATABASE_DEFAULT" + CatalogCollationTypeSQLLatinOneGeneralCPOneCIAS CatalogCollationType = "SQL_Latin1_General_CP1_CI_AS" +) + +func PossibleValuesForCatalogCollationType() []string { + return []string{ + string(CatalogCollationTypeDATABASEDEFAULT), + string(CatalogCollationTypeSQLLatinOneGeneralCPOneCIAS), + } +} + +func (s *CatalogCollationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCatalogCollationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCatalogCollationType(input string) (*CatalogCollationType, error) { + vals := map[string]CatalogCollationType{ + "database_default": CatalogCollationTypeDATABASEDEFAULT, + "sql_latin1_general_cp1_ci_as": CatalogCollationTypeSQLLatinOneGeneralCPOneCIAS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CatalogCollationType(input) + return &out, nil +} + +type ManagedDatabaseCreateMode string + +const ( + ManagedDatabaseCreateModeDefault ManagedDatabaseCreateMode = "Default" + ManagedDatabaseCreateModePointInTimeRestore ManagedDatabaseCreateMode = "PointInTimeRestore" + ManagedDatabaseCreateModeRecovery ManagedDatabaseCreateMode = "Recovery" + ManagedDatabaseCreateModeRestoreExternalBackup ManagedDatabaseCreateMode = "RestoreExternalBackup" + ManagedDatabaseCreateModeRestoreLongTermRetentionBackup ManagedDatabaseCreateMode = "RestoreLongTermRetentionBackup" +) + +func PossibleValuesForManagedDatabaseCreateMode() []string { + return []string{ + string(ManagedDatabaseCreateModeDefault), + string(ManagedDatabaseCreateModePointInTimeRestore), + string(ManagedDatabaseCreateModeRecovery), + string(ManagedDatabaseCreateModeRestoreExternalBackup), + string(ManagedDatabaseCreateModeRestoreLongTermRetentionBackup), + } +} + +func (s *ManagedDatabaseCreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedDatabaseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedDatabaseCreateMode(input string) (*ManagedDatabaseCreateMode, error) { + vals := map[string]ManagedDatabaseCreateMode{ + "default": ManagedDatabaseCreateModeDefault, + "pointintimerestore": ManagedDatabaseCreateModePointInTimeRestore, + "recovery": ManagedDatabaseCreateModeRecovery, + "restoreexternalbackup": ManagedDatabaseCreateModeRestoreExternalBackup, + "restorelongtermretentionbackup": ManagedDatabaseCreateModeRestoreLongTermRetentionBackup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedDatabaseCreateMode(input) + return &out, nil +} + +type ManagedDatabaseStatus string + +const ( + ManagedDatabaseStatusCreating ManagedDatabaseStatus = "Creating" + ManagedDatabaseStatusDbCopying ManagedDatabaseStatus = "DbCopying" + ManagedDatabaseStatusDbMoving ManagedDatabaseStatus = "DbMoving" + ManagedDatabaseStatusInaccessible ManagedDatabaseStatus = "Inaccessible" + ManagedDatabaseStatusOffline ManagedDatabaseStatus = "Offline" + ManagedDatabaseStatusOnline ManagedDatabaseStatus = "Online" + ManagedDatabaseStatusRestoring ManagedDatabaseStatus = "Restoring" + ManagedDatabaseStatusShutdown ManagedDatabaseStatus = "Shutdown" + ManagedDatabaseStatusStarting ManagedDatabaseStatus = "Starting" + ManagedDatabaseStatusStopped ManagedDatabaseStatus = "Stopped" + ManagedDatabaseStatusStopping ManagedDatabaseStatus = "Stopping" + ManagedDatabaseStatusUpdating ManagedDatabaseStatus = "Updating" +) + +func PossibleValuesForManagedDatabaseStatus() []string { + return []string{ + string(ManagedDatabaseStatusCreating), + string(ManagedDatabaseStatusDbCopying), + string(ManagedDatabaseStatusDbMoving), + string(ManagedDatabaseStatusInaccessible), + string(ManagedDatabaseStatusOffline), + string(ManagedDatabaseStatusOnline), + string(ManagedDatabaseStatusRestoring), + string(ManagedDatabaseStatusShutdown), + string(ManagedDatabaseStatusStarting), + string(ManagedDatabaseStatusStopped), + string(ManagedDatabaseStatusStopping), + string(ManagedDatabaseStatusUpdating), + } +} + +func (s *ManagedDatabaseStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedDatabaseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedDatabaseStatus(input string) (*ManagedDatabaseStatus, error) { + vals := map[string]ManagedDatabaseStatus{ + "creating": ManagedDatabaseStatusCreating, + "dbcopying": ManagedDatabaseStatusDbCopying, + "dbmoving": ManagedDatabaseStatusDbMoving, + "inaccessible": ManagedDatabaseStatusInaccessible, + "offline": ManagedDatabaseStatusOffline, + "online": ManagedDatabaseStatusOnline, + "restoring": ManagedDatabaseStatusRestoring, + "shutdown": ManagedDatabaseStatusShutdown, + "starting": ManagedDatabaseStatusStarting, + "stopped": ManagedDatabaseStatusStopped, + "stopping": ManagedDatabaseStatusStopping, + "updating": ManagedDatabaseStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedDatabaseStatus(input) + return &out, nil +} + +type MoveOperationMode string + +const ( + MoveOperationModeCopy MoveOperationMode = "Copy" + MoveOperationModeMove MoveOperationMode = "Move" +) + +func PossibleValuesForMoveOperationMode() []string { + return []string{ + string(MoveOperationModeCopy), + string(MoveOperationModeMove), + } +} + +func (s *MoveOperationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveOperationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMoveOperationMode(input string) (*MoveOperationMode, error) { + vals := map[string]MoveOperationMode{ + "copy": MoveOperationModeCopy, + "move": MoveOperationModeMove, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MoveOperationMode(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_cancelmove.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_cancelmove.go new file mode 100644 index 000000000000..2cc2e039670b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_cancelmove.go @@ -0,0 +1,75 @@ +package manageddatabases + +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/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 CancelMoveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CancelMove ... +func (c ManagedDatabasesClient) CancelMove(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseMoveDefinition) (result CancelMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelMove", 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 +} + +// CancelMoveThenPoll performs CancelMove then polls until it's completed +func (c ManagedDatabasesClient) CancelMoveThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseMoveDefinition) error { + result, err := c.CancelMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CancelMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CancelMove: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completemove.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completemove.go new file mode 100644 index 000000000000..c1fd322a686d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completemove.go @@ -0,0 +1,75 @@ +package manageddatabases + +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/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 CompleteMoveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CompleteMove ... +func (c ManagedDatabasesClient) CompleteMove(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseMoveDefinition) (result CompleteMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/completeMove", 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 +} + +// CompleteMoveThenPoll performs CompleteMove then polls until it's completed +func (c ManagedDatabasesClient) CompleteMoveThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseMoveDefinition) error { + result, err := c.CompleteMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CompleteMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CompleteMove: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completerestore.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completerestore.go new file mode 100644 index 000000000000..3117071e7445 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_completerestore.go @@ -0,0 +1,75 @@ +package manageddatabases + +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/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 CompleteRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CompleteRestore ... +func (c ManagedDatabasesClient) CompleteRestore(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input CompleteDatabaseRestoreDefinition) (result CompleteRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/completeRestore", 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 +} + +// CompleteRestoreThenPoll performs CompleteRestore then polls until it's completed +func (c ManagedDatabasesClient) CompleteRestoreThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input CompleteDatabaseRestoreDefinition) error { + result, err := c.CompleteRestore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CompleteRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CompleteRestore: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_createorupdate.go new file mode 100644 index 000000000000..a5a8a9596cf4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_createorupdate.go @@ -0,0 +1,77 @@ +package manageddatabases + +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/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 *ManagedDatabase +} + +// CreateOrUpdate ... +func (c ManagedDatabasesClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabase) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ManagedDatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabase) 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/sql/2023-08-01-preview/manageddatabases/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_delete.go new file mode 100644 index 000000000000..2ab242efe0d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_delete.go @@ -0,0 +1,72 @@ +package manageddatabases + +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/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 ManagedDatabasesClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (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 ManagedDatabasesClient) DeleteThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) 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/sql/2023-08-01-preview/manageddatabases/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_get.go new file mode 100644 index 000000000000..d04774f62a4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_get.go @@ -0,0 +1,55 @@ +package manageddatabases + +import ( + "context" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedDatabase +} + +// Get ... +func (c ManagedDatabasesClient) Get(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (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 ManagedDatabase + 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/sql/2023-08-01-preview/manageddatabases/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listbyinstance.go new file mode 100644 index 000000000000..f22159c138dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listbyinstance.go @@ -0,0 +1,106 @@ +package manageddatabases + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedDatabase +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedDatabase +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedDatabasesClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/databases", 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 *[]ManagedDatabase `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedDatabaseOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedDatabasesClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedDatabaseOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedDatabase, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listinaccessiblebyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listinaccessiblebyinstance.go new file mode 100644 index 000000000000..043eeee41ced --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_listinaccessiblebyinstance.go @@ -0,0 +1,106 @@ +package manageddatabases + +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 ListInaccessibleByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedDatabase +} + +type ListInaccessibleByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedDatabase +} + +type ListInaccessibleByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInaccessibleByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInaccessibleByInstance ... +func (c ManagedDatabasesClient) ListInaccessibleByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListInaccessibleByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInaccessibleByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/inaccessibleManagedDatabases", 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 *[]ManagedDatabase `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInaccessibleByInstanceComplete retrieves all the results into a single object +func (c ManagedDatabasesClient) ListInaccessibleByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListInaccessibleByInstanceCompleteResult, error) { + return c.ListInaccessibleByInstanceCompleteMatchingPredicate(ctx, id, ManagedDatabaseOperationPredicate{}) +} + +// ListInaccessibleByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedDatabasesClient) ListInaccessibleByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedDatabaseOperationPredicate) (result ListInaccessibleByInstanceCompleteResult, err error) { + items := make([]ManagedDatabase, 0) + + resp, err := c.ListInaccessibleByInstance(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 = ListInaccessibleByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_startmove.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_startmove.go new file mode 100644 index 000000000000..2167470d7cbf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_startmove.go @@ -0,0 +1,75 @@ +package manageddatabases + +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/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 StartMoveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StartMove ... +func (c ManagedDatabasesClient) StartMove(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseStartMoveDefinition) (result StartMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startMove", 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 +} + +// StartMoveThenPoll performs StartMove then polls until it's completed +func (c ManagedDatabasesClient) StartMoveThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseStartMoveDefinition) error { + result, err := c.StartMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StartMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartMove: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_update.go new file mode 100644 index 000000000000..84164bc95c1d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/method_update.go @@ -0,0 +1,76 @@ +package manageddatabases + +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/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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedDatabase +} + +// Update ... +func (c ManagedDatabasesClient) Update(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ManagedDatabasesClient) UpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedDatabaseUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_completedatabaserestoredefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_completedatabaserestoredefinition.go new file mode 100644 index 000000000000..eca7c8f98144 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_completedatabaserestoredefinition.go @@ -0,0 +1,8 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompleteDatabaseRestoreDefinition struct { + LastBackupName string `json:"lastBackupName"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabase.go new file mode 100644 index 000000000000..3fcbb3a4cd29 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabase.go @@ -0,0 +1,13 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDatabase struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedDatabaseProperties `json:"properties,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/sql/2023-08-01-preview/manageddatabases/model_manageddatabasemovedefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasemovedefinition.go new file mode 100644 index 000000000000..5bd6dac71102 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasemovedefinition.go @@ -0,0 +1,8 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDatabaseMoveDefinition struct { + DestinationManagedDatabaseId string `json:"destinationManagedDatabaseId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseproperties.go new file mode 100644 index 000000000000..e6cd3d04a2a0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseproperties.go @@ -0,0 +1,71 @@ +package manageddatabases + +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 ManagedDatabaseProperties struct { + AutoCompleteRestore *bool `json:"autoCompleteRestore,omitempty"` + CatalogCollation *CatalogCollationType `json:"catalogCollation,omitempty"` + Collation *string `json:"collation,omitempty"` + CreateMode *ManagedDatabaseCreateMode `json:"createMode,omitempty"` + CreationDate *string `json:"creationDate,omitempty"` + CrossSubscriptionRestorableDroppedDatabaseId *string `json:"crossSubscriptionRestorableDroppedDatabaseId,omitempty"` + CrossSubscriptionSourceDatabaseId *string `json:"crossSubscriptionSourceDatabaseId,omitempty"` + CrossSubscriptionTargetManagedInstanceId *string `json:"crossSubscriptionTargetManagedInstanceId,omitempty"` + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + EarliestRestorePoint *string `json:"earliestRestorePoint,omitempty"` + FailoverGroupId *string `json:"failoverGroupId,omitempty"` + IsLedgerOn *bool `json:"isLedgerOn,omitempty"` + LastBackupName *string `json:"lastBackupName,omitempty"` + LongTermRetentionBackupResourceId *string `json:"longTermRetentionBackupResourceId,omitempty"` + RecoverableDatabaseId *string `json:"recoverableDatabaseId,omitempty"` + RestorableDroppedDatabaseId *string `json:"restorableDroppedDatabaseId,omitempty"` + RestorePointInTime *string `json:"restorePointInTime,omitempty"` + SourceDatabaseId *string `json:"sourceDatabaseId,omitempty"` + Status *ManagedDatabaseStatus `json:"status,omitempty"` + StorageContainerIdentity *string `json:"storageContainerIdentity,omitempty"` + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + StorageContainerUri *string `json:"storageContainerUri,omitempty"` +} + +func (o *ManagedDatabaseProperties) GetCreationDateAsTime() (*time.Time, error) { + if o.CreationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedDatabaseProperties) SetCreationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationDate = &formatted +} + +func (o *ManagedDatabaseProperties) GetEarliestRestorePointAsTime() (*time.Time, error) { + if o.EarliestRestorePoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EarliestRestorePoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedDatabaseProperties) SetEarliestRestorePointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EarliestRestorePoint = &formatted +} + +func (o *ManagedDatabaseProperties) GetRestorePointInTimeAsTime() (*time.Time, error) { + if o.RestorePointInTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RestorePointInTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedDatabaseProperties) SetRestorePointInTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RestorePointInTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasestartmovedefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasestartmovedefinition.go new file mode 100644 index 000000000000..df0652a71e10 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabasestartmovedefinition.go @@ -0,0 +1,9 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDatabaseStartMoveDefinition struct { + DestinationManagedDatabaseId string `json:"destinationManagedDatabaseId"` + OperationMode *MoveOperationMode `json:"operationMode,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseupdate.go new file mode 100644 index 000000000000..d62817997280 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/model_manageddatabaseupdate.go @@ -0,0 +1,9 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDatabaseUpdate struct { + Properties *ManagedDatabaseProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/predicates.go new file mode 100644 index 000000000000..3841529c83ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/predicates.go @@ -0,0 +1,32 @@ +package manageddatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDatabaseOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedDatabaseOperationPredicate) Matches(input ManagedDatabase) 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/version.go new file mode 100644 index 000000000000..d965dc2294e2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases/version.go @@ -0,0 +1,12 @@ +package manageddatabases + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/manageddatabases/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/README.md new file mode 100644 index 000000000000..a11f59673000 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators` Documentation + +The `managedinstanceadministrators` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstanceadministrators" +``` + + +### Client Initialization + +```go +client := managedinstanceadministrators.NewManagedInstanceAdministratorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceAdministratorsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstanceadministrators.ManagedInstanceAdministrator{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceAdministratorsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceAdministratorsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +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: `ManagedInstanceAdministratorsClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/client.go new file mode 100644 index 000000000000..3f7e77dcf0f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/client.go @@ -0,0 +1,26 @@ +package managedinstanceadministrators + +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 ManagedInstanceAdministratorsClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceAdministratorsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceAdministratorsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstanceadministrators", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceAdministratorsClient: %+v", err) + } + + return &ManagedInstanceAdministratorsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/constants.go new file mode 100644 index 000000000000..fe42a0667583 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/constants.go @@ -0,0 +1,48 @@ +package managedinstanceadministrators + +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 ManagedInstanceAdministratorType string + +const ( + ManagedInstanceAdministratorTypeActiveDirectory ManagedInstanceAdministratorType = "ActiveDirectory" +) + +func PossibleValuesForManagedInstanceAdministratorType() []string { + return []string{ + string(ManagedInstanceAdministratorTypeActiveDirectory), + } +} + +func (s *ManagedInstanceAdministratorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedInstanceAdministratorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedInstanceAdministratorType(input string) (*ManagedInstanceAdministratorType, error) { + vals := map[string]ManagedInstanceAdministratorType{ + "activedirectory": ManagedInstanceAdministratorTypeActiveDirectory, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedInstanceAdministratorType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_createorupdate.go new file mode 100644 index 000000000000..9badd8f01f1e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_createorupdate.go @@ -0,0 +1,77 @@ +package managedinstanceadministrators + +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/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 *ManagedInstanceAdministrator +} + +// CreateOrUpdate ... +func (c ManagedInstanceAdministratorsClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceAdministrator) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 ManagedInstanceAdministratorsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceAdministrator) 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/sql/2023-08-01-preview/managedinstanceadministrators/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_delete.go new file mode 100644 index 000000000000..361291d66380 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_delete.go @@ -0,0 +1,71 @@ +package managedinstanceadministrators + +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/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 ManagedInstanceAdministratorsClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 ManagedInstanceAdministratorsClient) DeleteThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) 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/sql/2023-08-01-preview/managedinstanceadministrators/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_get.go new file mode 100644 index 000000000000..471776e28e8a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_get.go @@ -0,0 +1,56 @@ +package managedinstanceadministrators + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceAdministrator +} + +// Get ... +func (c ManagedInstanceAdministratorsClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 ManagedInstanceAdministrator + 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/sql/2023-08-01-preview/managedinstanceadministrators/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_listbyinstance.go new file mode 100644 index 000000000000..9bef3057cbd1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/method_listbyinstance.go @@ -0,0 +1,106 @@ +package managedinstanceadministrators + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceAdministrator +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceAdministrator +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedInstanceAdministratorsClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/administrators", 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 *[]ManagedInstanceAdministrator `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedInstanceAdministratorsClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedInstanceAdministratorOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceAdministratorsClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedInstanceAdministratorOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedInstanceAdministrator, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministrator.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministrator.go new file mode 100644 index 000000000000..a77cf4a72e1e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministrator.go @@ -0,0 +1,11 @@ +package managedinstanceadministrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAdministrator struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceAdministratorProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministratorproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministratorproperties.go new file mode 100644 index 000000000000..062aab44bdeb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/model_managedinstanceadministratorproperties.go @@ -0,0 +1,11 @@ +package managedinstanceadministrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAdministratorProperties struct { + AdministratorType ManagedInstanceAdministratorType `json:"administratorType"` + Login string `json:"login"` + Sid string `json:"sid"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/predicates.go new file mode 100644 index 000000000000..d8dcbcc98beb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/predicates.go @@ -0,0 +1,27 @@ +package managedinstanceadministrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAdministratorOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedInstanceAdministratorOperationPredicate) Matches(input ManagedInstanceAdministrator) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/version.go new file mode 100644 index 000000000000..47b4d51e30e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators/version.go @@ -0,0 +1,12 @@ +package managedinstanceadministrators + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstanceadministrators/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/README.md new file mode 100644 index 000000000000..dbdaadcfa03d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications` Documentation + +The `managedinstanceazureadonlyauthentications` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications" +``` + + +### Client Initialization + +```go +client := managedinstanceazureadonlyauthentications.NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceAzureADOnlyAuthenticationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstanceazureadonlyauthentications.ManagedInstanceAzureADOnlyAuthentication{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceAzureADOnlyAuthenticationsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceAzureADOnlyAuthenticationsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +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: `ManagedInstanceAzureADOnlyAuthenticationsClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/client.go new file mode 100644 index 000000000000..75cbb0831fd8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/client.go @@ -0,0 +1,26 @@ +package managedinstanceazureadonlyauthentications + +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 ManagedInstanceAzureADOnlyAuthenticationsClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceAzureADOnlyAuthenticationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstanceazureadonlyauthentications", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceAzureADOnlyAuthenticationsClient: %+v", err) + } + + return &ManagedInstanceAzureADOnlyAuthenticationsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_createorupdate.go new file mode 100644 index 000000000000..f19f00fc10ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_createorupdate.go @@ -0,0 +1,77 @@ +package managedinstanceazureadonlyauthentications + +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/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 *ManagedInstanceAzureADOnlyAuthentication +} + +// CreateOrUpdate ... +func (c ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceAzureADOnlyAuthentication) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/azureADOnlyAuthentications/default", 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 ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceAzureADOnlyAuthentication) 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/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_delete.go new file mode 100644 index 000000000000..d2e4dfa73c2e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_delete.go @@ -0,0 +1,72 @@ +package managedinstanceazureadonlyauthentications + +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/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 ManagedInstanceAzureADOnlyAuthenticationsClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceId) (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: fmt.Sprintf("%s/azureADOnlyAuthentications/default", 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 ManagedInstanceAzureADOnlyAuthenticationsClient) DeleteThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) 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/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_get.go new file mode 100644 index 000000000000..ad7d02117cc5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_get.go @@ -0,0 +1,56 @@ +package managedinstanceazureadonlyauthentications + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceAzureADOnlyAuthentication +} + +// Get ... +func (c ManagedInstanceAzureADOnlyAuthenticationsClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/azureADOnlyAuthentications/default", 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 ManagedInstanceAzureADOnlyAuthentication + 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/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_listbyinstance.go new file mode 100644 index 000000000000..4cd27d8d2714 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/method_listbyinstance.go @@ -0,0 +1,106 @@ +package managedinstanceazureadonlyauthentications + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceAzureADOnlyAuthentication +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceAzureADOnlyAuthentication +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/azureADOnlyAuthentications", 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 *[]ManagedInstanceAzureADOnlyAuthentication `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedInstanceAzureADOnlyAuthenticationOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedInstanceAzureADOnlyAuthenticationOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedInstanceAzureADOnlyAuthentication, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthentication.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthentication.go new file mode 100644 index 000000000000..9ad59f4b07c0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthentication.go @@ -0,0 +1,11 @@ +package managedinstanceazureadonlyauthentications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAzureADOnlyAuthentication struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceAzureADOnlyAuthProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthproperties.go new file mode 100644 index 000000000000..ffd1c383c025 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/model_managedinstanceazureadonlyauthproperties.go @@ -0,0 +1,8 @@ +package managedinstanceazureadonlyauthentications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAzureADOnlyAuthProperties struct { + AzureADOnlyAuthentication bool `json:"azureADOnlyAuthentication"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/predicates.go new file mode 100644 index 000000000000..26056826c212 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/predicates.go @@ -0,0 +1,27 @@ +package managedinstanceazureadonlyauthentications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceAzureADOnlyAuthenticationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedInstanceAzureADOnlyAuthenticationOperationPredicate) Matches(input ManagedInstanceAzureADOnlyAuthentication) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/version.go new file mode 100644 index 000000000000..c15dbd25db99 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications/version.go @@ -0,0 +1,12 @@ +package managedinstanceazureadonlyauthentications + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstanceazureadonlyauthentications/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/README.md new file mode 100644 index 000000000000..c4f23676c31a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors` Documentation + +The `managedinstanceencryptionprotectors` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstanceencryptionprotectors" +``` + + +### Client Initialization + +```go +client := managedinstanceencryptionprotectors.NewManagedInstanceEncryptionProtectorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceEncryptionProtectorsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstanceencryptionprotectors.ManagedInstanceEncryptionProtector{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceEncryptionProtectorsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +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: `ManagedInstanceEncryptionProtectorsClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstanceEncryptionProtectorsClient.Revalidate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.RevalidateThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/client.go new file mode 100644 index 000000000000..3688e97050ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/client.go @@ -0,0 +1,26 @@ +package managedinstanceencryptionprotectors + +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 ManagedInstanceEncryptionProtectorsClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceEncryptionProtectorsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceEncryptionProtectorsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstanceencryptionprotectors", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceEncryptionProtectorsClient: %+v", err) + } + + return &ManagedInstanceEncryptionProtectorsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/constants.go new file mode 100644 index 000000000000..334a5ec41afb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/constants.go @@ -0,0 +1,51 @@ +package managedinstanceencryptionprotectors + +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 ServerKeyType string + +const ( + ServerKeyTypeAzureKeyVault ServerKeyType = "AzureKeyVault" + ServerKeyTypeServiceManaged ServerKeyType = "ServiceManaged" +) + +func PossibleValuesForServerKeyType() []string { + return []string{ + string(ServerKeyTypeAzureKeyVault), + string(ServerKeyTypeServiceManaged), + } +} + +func (s *ServerKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerKeyType(input string) (*ServerKeyType, error) { + vals := map[string]ServerKeyType{ + "azurekeyvault": ServerKeyTypeAzureKeyVault, + "servicemanaged": ServerKeyTypeServiceManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerKeyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_createorupdate.go new file mode 100644 index 000000000000..27e82bc12a2d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedinstanceencryptionprotectors + +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/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 *ManagedInstanceEncryptionProtector +} + +// CreateOrUpdate ... +func (c ManagedInstanceEncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceEncryptionProtector) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/encryptionProtector/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceEncryptionProtector) 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/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_get.go new file mode 100644 index 000000000000..067629deb84a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_get.go @@ -0,0 +1,56 @@ +package managedinstanceencryptionprotectors + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceEncryptionProtector +} + +// Get ... +func (c ManagedInstanceEncryptionProtectorsClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/encryptionProtector/current", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedInstanceEncryptionProtector + 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/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_listbyinstance.go new file mode 100644 index 000000000000..92441270cccf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_listbyinstance.go @@ -0,0 +1,106 @@ +package managedinstanceencryptionprotectors + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceEncryptionProtector +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceEncryptionProtector +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedInstanceEncryptionProtectorsClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/encryptionProtector", 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 *[]ManagedInstanceEncryptionProtector `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedInstanceEncryptionProtectorsClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedInstanceEncryptionProtectorOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceEncryptionProtectorsClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedInstanceEncryptionProtectorOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedInstanceEncryptionProtector, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_revalidate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_revalidate.go new file mode 100644 index 000000000000..e51f2c2c4157 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/method_revalidate.go @@ -0,0 +1,71 @@ +package managedinstanceencryptionprotectors + +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/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 RevalidateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Revalidate ... +func (c ManagedInstanceEncryptionProtectorsClient) Revalidate(ctx context.Context, id commonids.SqlManagedInstanceId) (result RevalidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/encryptionProtector/current/revalidate", 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 +} + +// RevalidateThenPoll performs Revalidate then polls until it's completed +func (c ManagedInstanceEncryptionProtectorsClient) RevalidateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) error { + result, err := c.Revalidate(ctx, id) + if err != nil { + return fmt.Errorf("performing Revalidate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Revalidate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotector.go new file mode 100644 index 000000000000..6dbec21f08da --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotector.go @@ -0,0 +1,12 @@ +package managedinstanceencryptionprotectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceEncryptionProtector struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotectorproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotectorproperties.go new file mode 100644 index 000000000000..0b78a822cea4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/model_managedinstanceencryptionprotectorproperties.go @@ -0,0 +1,12 @@ +package managedinstanceencryptionprotectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceEncryptionProtectorProperties struct { + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` + ServerKeyName *string `json:"serverKeyName,omitempty"` + ServerKeyType ServerKeyType `json:"serverKeyType"` + Thumbprint *string `json:"thumbprint,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/predicates.go new file mode 100644 index 000000000000..3d36552bf7fc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/predicates.go @@ -0,0 +1,32 @@ +package managedinstanceencryptionprotectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceEncryptionProtectorOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ManagedInstanceEncryptionProtectorOperationPredicate) Matches(input ManagedInstanceEncryptionProtector) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/version.go new file mode 100644 index 000000000000..aa0f51f26d5a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors/version.go @@ -0,0 +1,12 @@ +package managedinstanceencryptionprotectors + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstanceencryptionprotectors/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/README.md new file mode 100644 index 000000000000..fff5fc692cc7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys` Documentation + +The `managedinstancekeys` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstancekeys" +``` + + +### Client Initialization + +```go +client := managedinstancekeys.NewManagedInstanceKeysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceKeysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedinstancekeys.NewManagedInstanceKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "keyValue") + +payload := managedinstancekeys.ManagedInstanceKey{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceKeysClient.Delete` + +```go +ctx := context.TODO() +id := managedinstancekeys.NewManagedInstanceKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "keyValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceKeysClient.Get` + +```go +ctx := context.TODO() +id := managedinstancekeys.NewManagedInstanceKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "keyValue") + +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: `ManagedInstanceKeysClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id, managedinstancekeys.DefaultListByInstanceOperationOptions())` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id, managedinstancekeys.DefaultListByInstanceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/client.go new file mode 100644 index 000000000000..06797198c4d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/client.go @@ -0,0 +1,26 @@ +package managedinstancekeys + +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 ManagedInstanceKeysClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstancekeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceKeysClient: %+v", err) + } + + return &ManagedInstanceKeysClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/constants.go new file mode 100644 index 000000000000..cb6c195b1a55 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/constants.go @@ -0,0 +1,51 @@ +package managedinstancekeys + +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 ServerKeyType string + +const ( + ServerKeyTypeAzureKeyVault ServerKeyType = "AzureKeyVault" + ServerKeyTypeServiceManaged ServerKeyType = "ServiceManaged" +) + +func PossibleValuesForServerKeyType() []string { + return []string{ + string(ServerKeyTypeAzureKeyVault), + string(ServerKeyTypeServiceManaged), + } +} + +func (s *ServerKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerKeyType(input string) (*ServerKeyType, error) { + vals := map[string]ServerKeyType{ + "azurekeyvault": ServerKeyTypeAzureKeyVault, + "servicemanaged": ServerKeyTypeServiceManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerKeyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/id_managedinstancekey.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/id_managedinstancekey.go new file mode 100644 index 000000000000..3636ab872d7d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/id_managedinstancekey.go @@ -0,0 +1,139 @@ +package managedinstancekeys + +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(&ManagedInstanceKeyId{}) +} + +var _ resourceids.ResourceId = &ManagedInstanceKeyId{} + +// ManagedInstanceKeyId is a struct representing the Resource ID for a Managed Instance Key +type ManagedInstanceKeyId struct { + SubscriptionId string + ResourceGroupName string + ManagedInstanceName string + KeyName string +} + +// NewManagedInstanceKeyID returns a new ManagedInstanceKeyId struct +func NewManagedInstanceKeyID(subscriptionId string, resourceGroupName string, managedInstanceName string, keyName string) ManagedInstanceKeyId { + return ManagedInstanceKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedInstanceName: managedInstanceName, + KeyName: keyName, + } +} + +// ParseManagedInstanceKeyID parses 'input' into a ManagedInstanceKeyId +func ParseManagedInstanceKeyID(input string) (*ManagedInstanceKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedInstanceKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedInstanceKeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedInstanceKeyIDInsensitively parses 'input' case-insensitively into a ManagedInstanceKeyId +// note: this method should only be used for API response data and not user input +func ParseManagedInstanceKeyIDInsensitively(input string) (*ManagedInstanceKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedInstanceKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedInstanceKeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedInstanceKeyId) 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.ManagedInstanceName, ok = input.Parsed["managedInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedInstanceName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateManagedInstanceKeyID checks that 'input' can be parsed as a Managed Instance Key ID +func ValidateManagedInstanceKeyID(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 := ParseManagedInstanceKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Instance Key ID +func (id ManagedInstanceKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Sql/managedInstances/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedInstanceName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Instance Key ID +func (id ManagedInstanceKeyId) 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("staticMicrosoftSql", "Microsoft.Sql", "Microsoft.Sql"), + resourceids.StaticSegment("staticManagedInstances", "managedInstances", "managedInstances"), + resourceids.UserSpecifiedSegment("managedInstanceName", "managedInstanceValue"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyValue"), + } +} + +// String returns a human-readable description of this Managed Instance Key ID +func (id ManagedInstanceKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Instance Name: %q", id.ManagedInstanceName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Managed Instance Key (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_createorupdate.go new file mode 100644 index 000000000000..6e098cfdd6ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedinstancekeys + +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 *ManagedInstanceKey +} + +// CreateOrUpdate ... +func (c ManagedInstanceKeysClient) CreateOrUpdate(ctx context.Context, id ManagedInstanceKeyId, input ManagedInstanceKey) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ManagedInstanceKeysClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedInstanceKeyId, input ManagedInstanceKey) 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/sql/2023-08-01-preview/managedinstancekeys/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_delete.go new file mode 100644 index 000000000000..5c7df47721e6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_delete.go @@ -0,0 +1,71 @@ +package managedinstancekeys + +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 ManagedInstanceKeysClient) Delete(ctx context.Context, id ManagedInstanceKeyId) (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 ManagedInstanceKeysClient) DeleteThenPoll(ctx context.Context, id ManagedInstanceKeyId) 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/sql/2023-08-01-preview/managedinstancekeys/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_get.go new file mode 100644 index 000000000000..c7d5ce953d0b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_get.go @@ -0,0 +1,54 @@ +package managedinstancekeys + +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 *ManagedInstanceKey +} + +// Get ... +func (c ManagedInstanceKeysClient) Get(ctx context.Context, id ManagedInstanceKeyId) (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 ManagedInstanceKey + 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/sql/2023-08-01-preview/managedinstancekeys/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_listbyinstance.go new file mode 100644 index 000000000000..140196d0475c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/method_listbyinstance.go @@ -0,0 +1,134 @@ +package managedinstancekeys + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceKey +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceKey +} + +type ListByInstanceOperationOptions struct { + Filter *string +} + +func DefaultListByInstanceOperationOptions() ListByInstanceOperationOptions { + return ListByInstanceOperationOptions{} +} + +func (o ListByInstanceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByInstanceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByInstanceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedInstanceKeysClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByInstanceOperationOptions) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/keys", 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 *[]ManagedInstanceKey `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedInstanceKeysClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByInstanceOperationOptions) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, options, ManagedInstanceKeyOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceKeysClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByInstanceOperationOptions, predicate ManagedInstanceKeyOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedInstanceKey, 0) + + resp, err := c.ListByInstance(ctx, id, options) + 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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekey.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekey.go new file mode 100644 index 000000000000..9be285e7e164 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekey.go @@ -0,0 +1,12 @@ +package managedinstancekeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceKey struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceKeyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekeyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekeyproperties.go new file mode 100644 index 000000000000..3c2e62946d07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/model_managedinstancekeyproperties.go @@ -0,0 +1,30 @@ +package managedinstancekeys + +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 ManagedInstanceKeyProperties struct { + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` + CreationDate *string `json:"creationDate,omitempty"` + ServerKeyType ServerKeyType `json:"serverKeyType"` + Thumbprint *string `json:"thumbprint,omitempty"` + Uri *string `json:"uri,omitempty"` +} + +func (o *ManagedInstanceKeyProperties) GetCreationDateAsTime() (*time.Time, error) { + if o.CreationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedInstanceKeyProperties) SetCreationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationDate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/predicates.go new file mode 100644 index 000000000000..9d02a4bfacd1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/predicates.go @@ -0,0 +1,32 @@ +package managedinstancekeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceKeyOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ManagedInstanceKeyOperationPredicate) Matches(input ManagedInstanceKey) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/version.go new file mode 100644 index 000000000000..843a1f45c7e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys/version.go @@ -0,0 +1,12 @@ +package managedinstancekeys + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstancekeys/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/README.md new file mode 100644 index 000000000000..dbe2eb4a02bf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies` Documentation + +The `managedinstancelongtermretentionpolicies` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies" +``` + + +### Client Initialization + +```go +client := managedinstancelongtermretentionpolicies.NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceLongTermRetentionPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +payload := managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceLongTermRetentionPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstanceLongTermRetentionPoliciesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +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: `ManagedInstanceLongTermRetentionPoliciesClient.ListByDatabase` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue", "databaseValue") + +// alternatively `client.ListByDatabase(ctx, id)` can be used to do batched pagination +items, err := client.ListByDatabaseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/client.go new file mode 100644 index 000000000000..d86d5f1cb6dc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/client.go @@ -0,0 +1,26 @@ +package managedinstancelongtermretentionpolicies + +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 ManagedInstanceLongTermRetentionPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceLongTermRetentionPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstancelongtermretentionpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceLongTermRetentionPoliciesClient: %+v", err) + } + + return &ManagedInstanceLongTermRetentionPoliciesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/constants.go new file mode 100644 index 000000000000..2b0562bc53c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/constants.go @@ -0,0 +1,51 @@ +package managedinstancelongtermretentionpolicies + +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 BackupStorageAccessTier string + +const ( + BackupStorageAccessTierArchive BackupStorageAccessTier = "Archive" + BackupStorageAccessTierHot BackupStorageAccessTier = "Hot" +) + +func PossibleValuesForBackupStorageAccessTier() []string { + return []string{ + string(BackupStorageAccessTierArchive), + string(BackupStorageAccessTierHot), + } +} + +func (s *BackupStorageAccessTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupStorageAccessTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupStorageAccessTier(input string) (*BackupStorageAccessTier, error) { + vals := map[string]BackupStorageAccessTier{ + "archive": BackupStorageAccessTierArchive, + "hot": BackupStorageAccessTierHot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupStorageAccessTier(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_createorupdate.go new file mode 100644 index 000000000000..4ffac25baa38 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedinstancelongtermretentionpolicies + +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/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 *ManagedInstanceLongTermRetentionPolicy +} + +// CreateOrUpdate ... +func (c ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedInstanceLongTermRetentionPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/backupLongTermRetentionPolicies/default", 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 ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, input ManagedInstanceLongTermRetentionPolicy) 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/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_delete.go new file mode 100644 index 000000000000..a4296652f906 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_delete.go @@ -0,0 +1,72 @@ +package managedinstancelongtermretentionpolicies + +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/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 + Model *ManagedInstanceLongTermRetentionPolicy +} + +// Delete ... +func (c ManagedInstanceLongTermRetentionPoliciesClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/backupLongTermRetentionPolicies/default", 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 ManagedInstanceLongTermRetentionPoliciesClient) DeleteThenPoll(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) 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/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_get.go new file mode 100644 index 000000000000..5d0631421515 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_get.go @@ -0,0 +1,56 @@ +package managedinstancelongtermretentionpolicies + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceLongTermRetentionPolicy +} + +// Get ... +func (c ManagedInstanceLongTermRetentionPoliciesClient) Get(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupLongTermRetentionPolicies/default", 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 ManagedInstanceLongTermRetentionPolicy + 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/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_listbydatabase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_listbydatabase.go new file mode 100644 index 000000000000..cf4ace859627 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/method_listbydatabase.go @@ -0,0 +1,106 @@ +package managedinstancelongtermretentionpolicies + +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 ListByDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceLongTermRetentionPolicy +} + +type ListByDatabaseCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceLongTermRetentionPolicy +} + +type ListByDatabaseCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByDatabaseCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByDatabase ... +func (c ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (result ListByDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByDatabaseCustomPager{}, + Path: fmt.Sprintf("%s/backupLongTermRetentionPolicies", 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 *[]ManagedInstanceLongTermRetentionPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByDatabaseComplete retrieves all the results into a single object +func (c ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId) (ListByDatabaseCompleteResult, error) { + return c.ListByDatabaseCompleteMatchingPredicate(ctx, id, ManagedInstanceLongTermRetentionPolicyOperationPredicate{}) +} + +// ListByDatabaseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceDatabaseId, predicate ManagedInstanceLongTermRetentionPolicyOperationPredicate) (result ListByDatabaseCompleteResult, err error) { + items := make([]ManagedInstanceLongTermRetentionPolicy, 0) + + resp, err := c.ListByDatabase(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 = ListByDatabaseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicy.go new file mode 100644 index 000000000000..130b2849778d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicy.go @@ -0,0 +1,11 @@ +package managedinstancelongtermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceLongTermRetentionPolicy struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceLongTermRetentionPolicyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicyproperties.go new file mode 100644 index 000000000000..1014c3709085 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/model_managedinstancelongtermretentionpolicyproperties.go @@ -0,0 +1,12 @@ +package managedinstancelongtermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceLongTermRetentionPolicyProperties struct { + BackupStorageAccessTier *BackupStorageAccessTier `json:"backupStorageAccessTier,omitempty"` + MonthlyRetention *string `json:"monthlyRetention,omitempty"` + WeekOfYear *int64 `json:"weekOfYear,omitempty"` + WeeklyRetention *string `json:"weeklyRetention,omitempty"` + YearlyRetention *string `json:"yearlyRetention,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/predicates.go new file mode 100644 index 000000000000..8ab8e0bab1f4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/predicates.go @@ -0,0 +1,27 @@ +package managedinstancelongtermretentionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceLongTermRetentionPolicyOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedInstanceLongTermRetentionPolicyOperationPredicate) Matches(input ManagedInstanceLongTermRetentionPolicy) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/version.go new file mode 100644 index 000000000000..f5e1a98083c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies/version.go @@ -0,0 +1,12 @@ +package managedinstancelongtermretentionpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstancelongtermretentionpolicies/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/README.md new file mode 100644 index 000000000000..7204ccc35e71 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/README.md @@ -0,0 +1,216 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances` Documentation + +The `managedinstances` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstances" +``` + + +### Client Initialization + +```go +client := managedinstances.NewManagedInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstancesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstances.ManagedInstance{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Failover` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.FailoverThenPoll(ctx, id, managedinstances.DefaultFailoverOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +read, err := client.Get(ctx, id, managedinstances.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedInstancesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, managedinstances.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, managedinstances.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstancesClient.ListByInstancePool` + +```go +ctx := context.TODO() +id := managedinstances.NewInstancePoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "instancePoolValue") + +// alternatively `client.ListByInstancePool(ctx, id, managedinstances.DefaultListByInstancePoolOperationOptions())` can be used to do batched pagination +items, err := client.ListByInstancePoolComplete(ctx, id, managedinstances.DefaultListByInstancePoolOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstancesClient.ListByManagedInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByManagedInstance(ctx, id, managedinstances.DefaultListByManagedInstanceOperationOptions())` can be used to do batched pagination +items, err := client.ListByManagedInstanceComplete(ctx, id, managedinstances.DefaultListByManagedInstanceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstancesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, managedinstances.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, managedinstances.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstancesClient.ListOutboundNetworkDependenciesByManagedInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListOutboundNetworkDependenciesByManagedInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListOutboundNetworkDependenciesByManagedInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedInstancesClient.RefreshStatus` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.RefreshStatusThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedInstancesClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstances.ManagedInstanceUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/client.go new file mode 100644 index 000000000000..0618c7ec8de4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/client.go @@ -0,0 +1,26 @@ +package managedinstances + +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 ManagedInstancesClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstancesClient: %+v", err) + } + + return &ManagedInstancesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/constants.go new file mode 100644 index 000000000000..5565835790ef --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/constants.go @@ -0,0 +1,834 @@ +package managedinstances + +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 AdministratorType string + +const ( + AdministratorTypeActiveDirectory AdministratorType = "ActiveDirectory" +) + +func PossibleValuesForAdministratorType() []string { + return []string{ + string(AdministratorTypeActiveDirectory), + } +} + +func (s *AdministratorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdministratorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdministratorType(input string) (*AdministratorType, error) { + vals := map[string]AdministratorType{ + "activedirectory": AdministratorTypeActiveDirectory, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdministratorType(input) + return &out, nil +} + +type AggregationFunctionType string + +const ( + AggregationFunctionTypeAvg AggregationFunctionType = "avg" + AggregationFunctionTypeMax AggregationFunctionType = "max" + AggregationFunctionTypeMin AggregationFunctionType = "min" + AggregationFunctionTypeStdev AggregationFunctionType = "stdev" + AggregationFunctionTypeSum AggregationFunctionType = "sum" +) + +func PossibleValuesForAggregationFunctionType() []string { + return []string{ + string(AggregationFunctionTypeAvg), + string(AggregationFunctionTypeMax), + string(AggregationFunctionTypeMin), + string(AggregationFunctionTypeStdev), + string(AggregationFunctionTypeSum), + } +} + +func (s *AggregationFunctionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAggregationFunctionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAggregationFunctionType(input string) (*AggregationFunctionType, error) { + vals := map[string]AggregationFunctionType{ + "avg": AggregationFunctionTypeAvg, + "max": AggregationFunctionTypeMax, + "min": AggregationFunctionTypeMin, + "stdev": AggregationFunctionTypeStdev, + "sum": AggregationFunctionTypeSum, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AggregationFunctionType(input) + return &out, nil +} + +type AuthMetadataLookupModes string + +const ( + AuthMetadataLookupModesAzureAD AuthMetadataLookupModes = "AzureAD" + AuthMetadataLookupModesPaired AuthMetadataLookupModes = "Paired" + AuthMetadataLookupModesWindows AuthMetadataLookupModes = "Windows" +) + +func PossibleValuesForAuthMetadataLookupModes() []string { + return []string{ + string(AuthMetadataLookupModesAzureAD), + string(AuthMetadataLookupModesPaired), + string(AuthMetadataLookupModesWindows), + } +} + +func (s *AuthMetadataLookupModes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthMetadataLookupModes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthMetadataLookupModes(input string) (*AuthMetadataLookupModes, error) { + vals := map[string]AuthMetadataLookupModes{ + "azuread": AuthMetadataLookupModesAzureAD, + "paired": AuthMetadataLookupModesPaired, + "windows": AuthMetadataLookupModesWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthMetadataLookupModes(input) + return &out, nil +} + +type BackupStorageRedundancy string + +const ( + BackupStorageRedundancyGeo BackupStorageRedundancy = "Geo" + BackupStorageRedundancyGeoZone BackupStorageRedundancy = "GeoZone" + BackupStorageRedundancyLocal BackupStorageRedundancy = "Local" + BackupStorageRedundancyZone BackupStorageRedundancy = "Zone" +) + +func PossibleValuesForBackupStorageRedundancy() []string { + return []string{ + string(BackupStorageRedundancyGeo), + string(BackupStorageRedundancyGeoZone), + string(BackupStorageRedundancyLocal), + string(BackupStorageRedundancyZone), + } +} + +func (s *BackupStorageRedundancy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupStorageRedundancy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupStorageRedundancy(input string) (*BackupStorageRedundancy, error) { + vals := map[string]BackupStorageRedundancy{ + "geo": BackupStorageRedundancyGeo, + "geozone": BackupStorageRedundancyGeoZone, + "local": BackupStorageRedundancyLocal, + "zone": BackupStorageRedundancyZone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupStorageRedundancy(input) + return &out, nil +} + +type ExternalGovernanceStatus string + +const ( + ExternalGovernanceStatusDisabled ExternalGovernanceStatus = "Disabled" + ExternalGovernanceStatusEnabled ExternalGovernanceStatus = "Enabled" +) + +func PossibleValuesForExternalGovernanceStatus() []string { + return []string{ + string(ExternalGovernanceStatusDisabled), + string(ExternalGovernanceStatusEnabled), + } +} + +func (s *ExternalGovernanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExternalGovernanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExternalGovernanceStatus(input string) (*ExternalGovernanceStatus, error) { + vals := map[string]ExternalGovernanceStatus{ + "disabled": ExternalGovernanceStatusDisabled, + "enabled": ExternalGovernanceStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExternalGovernanceStatus(input) + return &out, nil +} + +type FreemiumType string + +const ( + FreemiumTypeFreemium FreemiumType = "Freemium" + FreemiumTypeRegular FreemiumType = "Regular" +) + +func PossibleValuesForFreemiumType() []string { + return []string{ + string(FreemiumTypeFreemium), + string(FreemiumTypeRegular), + } +} + +func (s *FreemiumType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFreemiumType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFreemiumType(input string) (*FreemiumType, error) { + vals := map[string]FreemiumType{ + "freemium": FreemiumTypeFreemium, + "regular": FreemiumTypeRegular, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FreemiumType(input) + return &out, nil +} + +type HybridSecondaryUsage string + +const ( + HybridSecondaryUsageActive HybridSecondaryUsage = "Active" + HybridSecondaryUsagePassive HybridSecondaryUsage = "Passive" +) + +func PossibleValuesForHybridSecondaryUsage() []string { + return []string{ + string(HybridSecondaryUsageActive), + string(HybridSecondaryUsagePassive), + } +} + +func (s *HybridSecondaryUsage) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHybridSecondaryUsage(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHybridSecondaryUsage(input string) (*HybridSecondaryUsage, error) { + vals := map[string]HybridSecondaryUsage{ + "active": HybridSecondaryUsageActive, + "passive": HybridSecondaryUsagePassive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HybridSecondaryUsage(input) + return &out, nil +} + +type HybridSecondaryUsageDetected string + +const ( + HybridSecondaryUsageDetectedActive HybridSecondaryUsageDetected = "Active" + HybridSecondaryUsageDetectedPassive HybridSecondaryUsageDetected = "Passive" +) + +func PossibleValuesForHybridSecondaryUsageDetected() []string { + return []string{ + string(HybridSecondaryUsageDetectedActive), + string(HybridSecondaryUsageDetectedPassive), + } +} + +func (s *HybridSecondaryUsageDetected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHybridSecondaryUsageDetected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHybridSecondaryUsageDetected(input string) (*HybridSecondaryUsageDetected, error) { + vals := map[string]HybridSecondaryUsageDetected{ + "active": HybridSecondaryUsageDetectedActive, + "passive": HybridSecondaryUsageDetectedPassive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HybridSecondaryUsageDetected(input) + return &out, nil +} + +type ManagedInstanceDatabaseFormat string + +const ( + ManagedInstanceDatabaseFormatAlwaysUpToDate ManagedInstanceDatabaseFormat = "AlwaysUpToDate" + ManagedInstanceDatabaseFormatSQLServerTwoZeroTwoTwo ManagedInstanceDatabaseFormat = "SQLServer2022" +) + +func PossibleValuesForManagedInstanceDatabaseFormat() []string { + return []string{ + string(ManagedInstanceDatabaseFormatAlwaysUpToDate), + string(ManagedInstanceDatabaseFormatSQLServerTwoZeroTwoTwo), + } +} + +func (s *ManagedInstanceDatabaseFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedInstanceDatabaseFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedInstanceDatabaseFormat(input string) (*ManagedInstanceDatabaseFormat, error) { + vals := map[string]ManagedInstanceDatabaseFormat{ + "alwaysuptodate": ManagedInstanceDatabaseFormatAlwaysUpToDate, + "sqlserver2022": ManagedInstanceDatabaseFormatSQLServerTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedInstanceDatabaseFormat(input) + return &out, nil +} + +type ManagedInstanceLicenseType string + +const ( + ManagedInstanceLicenseTypeBasePrice ManagedInstanceLicenseType = "BasePrice" + ManagedInstanceLicenseTypeLicenseIncluded ManagedInstanceLicenseType = "LicenseIncluded" +) + +func PossibleValuesForManagedInstanceLicenseType() []string { + return []string{ + string(ManagedInstanceLicenseTypeBasePrice), + string(ManagedInstanceLicenseTypeLicenseIncluded), + } +} + +func (s *ManagedInstanceLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedInstanceLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedInstanceLicenseType(input string) (*ManagedInstanceLicenseType, error) { + vals := map[string]ManagedInstanceLicenseType{ + "baseprice": ManagedInstanceLicenseTypeBasePrice, + "licenseincluded": ManagedInstanceLicenseTypeLicenseIncluded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedInstanceLicenseType(input) + return &out, nil +} + +type ManagedInstanceProxyOverride string + +const ( + ManagedInstanceProxyOverrideDefault ManagedInstanceProxyOverride = "Default" + ManagedInstanceProxyOverrideProxy ManagedInstanceProxyOverride = "Proxy" + ManagedInstanceProxyOverrideRedirect ManagedInstanceProxyOverride = "Redirect" +) + +func PossibleValuesForManagedInstanceProxyOverride() []string { + return []string{ + string(ManagedInstanceProxyOverrideDefault), + string(ManagedInstanceProxyOverrideProxy), + string(ManagedInstanceProxyOverrideRedirect), + } +} + +func (s *ManagedInstanceProxyOverride) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedInstanceProxyOverride(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedInstanceProxyOverride(input string) (*ManagedInstanceProxyOverride, error) { + vals := map[string]ManagedInstanceProxyOverride{ + "default": ManagedInstanceProxyOverrideDefault, + "proxy": ManagedInstanceProxyOverrideProxy, + "redirect": ManagedInstanceProxyOverrideRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedInstanceProxyOverride(input) + return &out, nil +} + +type ManagedServerCreateMode string + +const ( + ManagedServerCreateModeDefault ManagedServerCreateMode = "Default" + ManagedServerCreateModePointInTimeRestore ManagedServerCreateMode = "PointInTimeRestore" +) + +func PossibleValuesForManagedServerCreateMode() []string { + return []string{ + string(ManagedServerCreateModeDefault), + string(ManagedServerCreateModePointInTimeRestore), + } +} + +func (s *ManagedServerCreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServerCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServerCreateMode(input string) (*ManagedServerCreateMode, error) { + vals := map[string]ManagedServerCreateMode{ + "default": ManagedServerCreateModeDefault, + "pointintimerestore": ManagedServerCreateModePointInTimeRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServerCreateMode(input) + return &out, nil +} + +type MetricType string + +const ( + MetricTypeCpu MetricType = "cpu" + MetricTypeDtu MetricType = "dtu" + MetricTypeDuration MetricType = "duration" + MetricTypeIo MetricType = "io" + MetricTypeLogIo MetricType = "logIo" +) + +func PossibleValuesForMetricType() []string { + return []string{ + string(MetricTypeCpu), + string(MetricTypeDtu), + string(MetricTypeDuration), + string(MetricTypeIo), + string(MetricTypeLogIo), + } +} + +func (s *MetricType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMetricType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMetricType(input string) (*MetricType, error) { + vals := map[string]MetricType{ + "cpu": MetricTypeCpu, + "dtu": MetricTypeDtu, + "duration": MetricTypeDuration, + "io": MetricTypeIo, + "logio": MetricTypeLogIo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MetricType(input) + return &out, nil +} + +type PrincipalType string + +const ( + PrincipalTypeApplication PrincipalType = "Application" + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeUser PrincipalType = "User" +) + +func PossibleValuesForPrincipalType() []string { + return []string{ + string(PrincipalTypeApplication), + string(PrincipalTypeGroup), + string(PrincipalTypeUser), + } +} + +func (s *PrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalType(input string) (*PrincipalType, error) { + vals := map[string]PrincipalType{ + "application": PrincipalTypeApplication, + "group": PrincipalTypeGroup, + "user": PrincipalTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreated), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +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{ + "canceled": ProvisioningStateCanceled, + "created": ProvisioningStateCreated, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + 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 QueryMetricUnitType string + +const ( + QueryMetricUnitTypeCount QueryMetricUnitType = "count" + QueryMetricUnitTypeKB QueryMetricUnitType = "KB" + QueryMetricUnitTypeMicroseconds QueryMetricUnitType = "microseconds" + QueryMetricUnitTypePercentage QueryMetricUnitType = "percentage" +) + +func PossibleValuesForQueryMetricUnitType() []string { + return []string{ + string(QueryMetricUnitTypeCount), + string(QueryMetricUnitTypeKB), + string(QueryMetricUnitTypeMicroseconds), + string(QueryMetricUnitTypePercentage), + } +} + +func (s *QueryMetricUnitType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryMetricUnitType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryMetricUnitType(input string) (*QueryMetricUnitType, error) { + vals := map[string]QueryMetricUnitType{ + "count": QueryMetricUnitTypeCount, + "kb": QueryMetricUnitTypeKB, + "microseconds": QueryMetricUnitTypeMicroseconds, + "percentage": QueryMetricUnitTypePercentage, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryMetricUnitType(input) + return &out, nil +} + +type QueryTimeGrainType string + +const ( + QueryTimeGrainTypePOneD QueryTimeGrainType = "P1D" + QueryTimeGrainTypePTOneH QueryTimeGrainType = "PT1H" +) + +func PossibleValuesForQueryTimeGrainType() []string { + return []string{ + string(QueryTimeGrainTypePOneD), + string(QueryTimeGrainTypePTOneH), + } +} + +func (s *QueryTimeGrainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryTimeGrainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryTimeGrainType(input string) (*QueryTimeGrainType, error) { + vals := map[string]QueryTimeGrainType{ + "p1d": QueryTimeGrainTypePOneD, + "pt1h": QueryTimeGrainTypePTOneH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryTimeGrainType(input) + return &out, nil +} + +type ReplicaType string + +const ( + ReplicaTypePrimary ReplicaType = "Primary" + ReplicaTypeReadableSecondary ReplicaType = "ReadableSecondary" +) + +func PossibleValuesForReplicaType() []string { + return []string{ + string(ReplicaTypePrimary), + string(ReplicaTypeReadableSecondary), + } +} + +func (s *ReplicaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicaType(input string) (*ReplicaType, error) { + vals := map[string]ReplicaType{ + "primary": ReplicaTypePrimary, + "readablesecondary": ReplicaTypeReadableSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicaType(input) + return &out, nil +} + +type ServicePrincipalType string + +const ( + ServicePrincipalTypeNone ServicePrincipalType = "None" + ServicePrincipalTypeSystemAssigned ServicePrincipalType = "SystemAssigned" +) + +func PossibleValuesForServicePrincipalType() []string { + return []string{ + string(ServicePrincipalTypeNone), + string(ServicePrincipalTypeSystemAssigned), + } +} + +func (s *ServicePrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServicePrincipalType(input string) (*ServicePrincipalType, error) { + vals := map[string]ServicePrincipalType{ + "none": ServicePrincipalTypeNone, + "systemassigned": ServicePrincipalTypeSystemAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServicePrincipalType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/id_instancepool.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/id_instancepool.go new file mode 100644 index 000000000000..c4d1f83519fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/id_instancepool.go @@ -0,0 +1,130 @@ +package managedinstances + +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(&InstancePoolId{}) +} + +var _ resourceids.ResourceId = &InstancePoolId{} + +// InstancePoolId is a struct representing the Resource ID for a Instance Pool +type InstancePoolId struct { + SubscriptionId string + ResourceGroupName string + InstancePoolName string +} + +// NewInstancePoolID returns a new InstancePoolId struct +func NewInstancePoolID(subscriptionId string, resourceGroupName string, instancePoolName string) InstancePoolId { + return InstancePoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + InstancePoolName: instancePoolName, + } +} + +// ParseInstancePoolID parses 'input' into a InstancePoolId +func ParseInstancePoolID(input string) (*InstancePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstancePoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstancePoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstancePoolIDInsensitively parses 'input' case-insensitively into a InstancePoolId +// note: this method should only be used for API response data and not user input +func ParseInstancePoolIDInsensitively(input string) (*InstancePoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstancePoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstancePoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstancePoolId) 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.InstancePoolName, ok = input.Parsed["instancePoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instancePoolName", input) + } + + return nil +} + +// ValidateInstancePoolID checks that 'input' can be parsed as a Instance Pool ID +func ValidateInstancePoolID(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 := ParseInstancePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Pool ID +func (id InstancePoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Sql/instancePools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.InstancePoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Pool ID +func (id InstancePoolId) 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("staticMicrosoftSql", "Microsoft.Sql", "Microsoft.Sql"), + resourceids.StaticSegment("staticInstancePools", "instancePools", "instancePools"), + resourceids.UserSpecifiedSegment("instancePoolName", "instancePoolValue"), + } +} + +// String returns a human-readable description of this Instance Pool ID +func (id InstancePoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Instance Pool Name: %q", id.InstancePoolName), + } + return fmt.Sprintf("Instance Pool (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_createorupdate.go new file mode 100644 index 000000000000..64419f9cc8b8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_createorupdate.go @@ -0,0 +1,77 @@ +package managedinstances + +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/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 *ManagedInstance +} + +// CreateOrUpdate ... +func (c ManagedInstancesClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstance) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ManagedInstancesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstance) 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/sql/2023-08-01-preview/managedinstances/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_delete.go new file mode 100644 index 000000000000..71a0c4e1c3d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_delete.go @@ -0,0 +1,72 @@ +package managedinstances + +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/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 ManagedInstancesClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceId) (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 ManagedInstancesClient) DeleteThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) 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/sql/2023-08-01-preview/managedinstances/method_failover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_failover.go new file mode 100644 index 000000000000..6a09e24ad410 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_failover.go @@ -0,0 +1,99 @@ +package managedinstances + +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/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 FailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type FailoverOperationOptions struct { + ReplicaType *ReplicaType +} + +func DefaultFailoverOperationOptions() FailoverOperationOptions { + return FailoverOperationOptions{} +} + +func (o FailoverOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o FailoverOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o FailoverOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ReplicaType != nil { + out.Append("replicaType", fmt.Sprintf("%v", *o.ReplicaType)) + } + return &out +} + +// Failover ... +func (c ManagedInstancesClient) Failover(ctx context.Context, id commonids.SqlManagedInstanceId, options FailoverOperationOptions) (result FailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/failover", 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 +} + +// FailoverThenPoll performs Failover then polls until it's completed +func (c ManagedInstancesClient) FailoverThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, options FailoverOperationOptions) error { + result, err := c.Failover(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Failover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Failover: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_get.go new file mode 100644 index 000000000000..2c318ce242db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_get.go @@ -0,0 +1,84 @@ +package managedinstances + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstance +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c ManagedInstancesClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 ManagedInstance + 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/sql/2023-08-01-preview/managedinstances/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_list.go new file mode 100644 index 000000000000..55f688b91aca --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_list.go @@ -0,0 +1,134 @@ +package managedinstances + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstance +} + +type ListOperationOptions struct { + Expand *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ManagedInstancesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Sql/managedInstances", 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 *[]ManagedInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ManagedInstancesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ManagedInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ManagedInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedInstance, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyinstancepool.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyinstancepool.go new file mode 100644 index 000000000000..f98c7ba29014 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyinstancepool.go @@ -0,0 +1,133 @@ +package managedinstances + +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 ListByInstancePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstance +} + +type ListByInstancePoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstance +} + +type ListByInstancePoolOperationOptions struct { + Expand *string +} + +func DefaultListByInstancePoolOperationOptions() ListByInstancePoolOperationOptions { + return ListByInstancePoolOperationOptions{} +} + +func (o ListByInstancePoolOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByInstancePoolOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByInstancePoolOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +type ListByInstancePoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstancePoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstancePool ... +func (c ManagedInstancesClient) ListByInstancePool(ctx context.Context, id InstancePoolId, options ListByInstancePoolOperationOptions) (result ListByInstancePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByInstancePoolCustomPager{}, + Path: fmt.Sprintf("%s/managedInstances", 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 *[]ManagedInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstancePoolComplete retrieves all the results into a single object +func (c ManagedInstancesClient) ListByInstancePoolComplete(ctx context.Context, id InstancePoolId, options ListByInstancePoolOperationOptions) (ListByInstancePoolCompleteResult, error) { + return c.ListByInstancePoolCompleteMatchingPredicate(ctx, id, options, ManagedInstanceOperationPredicate{}) +} + +// ListByInstancePoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstancesClient) ListByInstancePoolCompleteMatchingPredicate(ctx context.Context, id InstancePoolId, options ListByInstancePoolOperationOptions, predicate ManagedInstanceOperationPredicate) (result ListByInstancePoolCompleteResult, err error) { + items := make([]ManagedInstance, 0) + + resp, err := c.ListByInstancePool(ctx, id, options) + 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 = ListByInstancePoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbymanagedinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbymanagedinstance.go new file mode 100644 index 000000000000..8a7c6f76675a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbymanagedinstance.go @@ -0,0 +1,158 @@ +package managedinstances + +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 ListByManagedInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TopQueries +} + +type ListByManagedInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []TopQueries +} + +type ListByManagedInstanceOperationOptions struct { + AggregationFunction *AggregationFunctionType + Databases *string + EndTime *string + Interval *QueryTimeGrainType + NumberOfQueries *int64 + ObservationMetric *MetricType + StartTime *string +} + +func DefaultListByManagedInstanceOperationOptions() ListByManagedInstanceOperationOptions { + return ListByManagedInstanceOperationOptions{} +} + +func (o ListByManagedInstanceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByManagedInstanceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByManagedInstanceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AggregationFunction != nil { + out.Append("aggregationFunction", fmt.Sprintf("%v", *o.AggregationFunction)) + } + if o.Databases != nil { + out.Append("databases", fmt.Sprintf("%v", *o.Databases)) + } + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.Interval != nil { + out.Append("interval", fmt.Sprintf("%v", *o.Interval)) + } + if o.NumberOfQueries != nil { + out.Append("numberOfQueries", fmt.Sprintf("%v", *o.NumberOfQueries)) + } + if o.ObservationMetric != nil { + out.Append("observationMetric", fmt.Sprintf("%v", *o.ObservationMetric)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + return &out +} + +type ListByManagedInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagedInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagedInstance ... +func (c ManagedInstancesClient) ListByManagedInstance(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByManagedInstanceOperationOptions) (result ListByManagedInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByManagedInstanceCustomPager{}, + Path: fmt.Sprintf("%s/topqueries", 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 *[]TopQueries `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedInstanceComplete retrieves all the results into a single object +func (c ManagedInstancesClient) ListByManagedInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByManagedInstanceOperationOptions) (ListByManagedInstanceCompleteResult, error) { + return c.ListByManagedInstanceCompleteMatchingPredicate(ctx, id, options, TopQueriesOperationPredicate{}) +} + +// ListByManagedInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstancesClient) ListByManagedInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, options ListByManagedInstanceOperationOptions, predicate TopQueriesOperationPredicate) (result ListByManagedInstanceCompleteResult, err error) { + items := make([]TopQueries, 0) + + resp, err := c.ListByManagedInstance(ctx, id, options) + 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 = ListByManagedInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyresourcegroup.go new file mode 100644 index 000000000000..0a8a15041c2b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listbyresourcegroup.go @@ -0,0 +1,134 @@ +package managedinstances + +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 *[]ManagedInstance +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstance +} + +type ListByResourceGroupOperationOptions struct { + Expand *string +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +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 ManagedInstancesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Sql/managedInstances", 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 *[]ManagedInstance `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 ManagedInstancesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ManagedInstanceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstancesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ManagedInstanceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedInstance, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/sql/2023-08-01-preview/managedinstances/method_listoutboundnetworkdependenciesbymanagedinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listoutboundnetworkdependenciesbymanagedinstance.go new file mode 100644 index 000000000000..e2bcb4e0daa2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_listoutboundnetworkdependenciesbymanagedinstance.go @@ -0,0 +1,106 @@ +package managedinstances + +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 ListOutboundNetworkDependenciesByManagedInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesByManagedInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesByManagedInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListOutboundNetworkDependenciesByManagedInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListOutboundNetworkDependenciesByManagedInstance ... +func (c ManagedInstancesClient) ListOutboundNetworkDependenciesByManagedInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListOutboundNetworkDependenciesByManagedInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListOutboundNetworkDependenciesByManagedInstanceCustomPager{}, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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 *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOutboundNetworkDependenciesByManagedInstanceComplete retrieves all the results into a single object +func (c ManagedInstancesClient) ListOutboundNetworkDependenciesByManagedInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListOutboundNetworkDependenciesByManagedInstanceCompleteResult, error) { + return c.ListOutboundNetworkDependenciesByManagedInstanceCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// ListOutboundNetworkDependenciesByManagedInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstancesClient) ListOutboundNetworkDependenciesByManagedInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate OutboundEnvironmentEndpointOperationPredicate) (result ListOutboundNetworkDependenciesByManagedInstanceCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.ListOutboundNetworkDependenciesByManagedInstance(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 = ListOutboundNetworkDependenciesByManagedInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_refreshstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_refreshstatus.go new file mode 100644 index 000000000000..77b456fd23ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_refreshstatus.go @@ -0,0 +1,72 @@ +package managedinstances + +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/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 RefreshStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RefreshExternalGovernanceStatusOperationResultMI +} + +// RefreshStatus ... +func (c ManagedInstancesClient) RefreshStatus(ctx context.Context, id commonids.SqlManagedInstanceId) (result RefreshStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshExternalGovernanceStatus", 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 +} + +// RefreshStatusThenPoll performs RefreshStatus then polls until it's completed +func (c ManagedInstancesClient) RefreshStatusThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) error { + result, err := c.RefreshStatus(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshStatus: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_start.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_start.go new file mode 100644 index 000000000000..0f9420be74c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_start.go @@ -0,0 +1,72 @@ +package managedinstances + +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/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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstance +} + +// Start ... +func (c ManagedInstancesClient) Start(ctx context.Context, id commonids.SqlManagedInstanceId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c ManagedInstancesClient) StartThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_stop.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_stop.go new file mode 100644 index 000000000000..d9c3c3ae52d7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_stop.go @@ -0,0 +1,72 @@ +package managedinstances + +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/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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstance +} + +// Stop ... +func (c ManagedInstancesClient) Stop(ctx context.Context, id commonids.SqlManagedInstanceId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ManagedInstancesClient) StopThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_update.go new file mode 100644 index 000000000000..f2ebe4da4fd6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/method_update.go @@ -0,0 +1,76 @@ +package managedinstances + +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/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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstance +} + +// Update ... +func (c ManagedInstancesClient) Update(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ManagedInstancesClient) UpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdependency.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdependency.go new file mode 100644 index 000000000000..6536aa85d3f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdependency.go @@ -0,0 +1,9 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdetail.go new file mode 100644 index 000000000000..54168cb31cae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_endpointdetail.go @@ -0,0 +1,8 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + Port *int64 `json:"port,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstance.go new file mode 100644 index 000000000000..c14c46bf1ff4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstance.go @@ -0,0 +1,19 @@ +package managedinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstance struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,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/sql/2023-08-01-preview/managedinstances/model_managedinstanceexternaladministrator.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceexternaladministrator.go new file mode 100644 index 000000000000..9844de053071 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceexternaladministrator.go @@ -0,0 +1,13 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceExternalAdministrator struct { + AdministratorType *AdministratorType `json:"administratorType,omitempty"` + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` + Login *string `json:"login,omitempty"` + PrincipalType *PrincipalType `json:"principalType,omitempty"` + Sid *string `json:"sid,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstancepecproperty.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstancepecproperty.go new file mode 100644 index 000000000000..4e5c5ab6e59e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstancepecproperty.go @@ -0,0 +1,9 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstancePecProperty struct { + Id *string `json:"id,omitempty"` + Properties *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointconnectionproperties.go new file mode 100644 index 000000000000..6bad8545c613 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstancePrivateEndpointConnectionProperties struct { + PrivateEndpoint *ManagedInstancePrivateEndpointProperty `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *ManagedInstancePrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointproperty.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointproperty.go new file mode 100644 index 000000000000..0f993e64d0d4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivateendpointproperty.go @@ -0,0 +1,8 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstancePrivateEndpointProperty struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivatelinkserviceconnectionstateproperty.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivatelinkserviceconnectionstateproperty.go new file mode 100644 index 000000000000..6c2f28784bc7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceprivatelinkserviceconnectionstateproperty.go @@ -0,0 +1,10 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstancePrivateLinkServiceConnectionStateProperty struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description string `json:"description"` + Status string `json:"status"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceproperties.go new file mode 100644 index 000000000000..e6817c5cac20 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceproperties.go @@ -0,0 +1,78 @@ +package managedinstances + +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 ManagedInstanceProperties struct { + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + Administrators *ManagedInstanceExternalAdministrator `json:"administrators,omitempty"` + AuthenticationMetadata *AuthMetadataLookupModes `json:"authenticationMetadata,omitempty"` + Collation *string `json:"collation,omitempty"` + CreateTime *string `json:"createTime,omitempty"` + CurrentBackupStorageRedundancy *BackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + DatabaseFormat *ManagedInstanceDatabaseFormat `json:"databaseFormat,omitempty"` + DnsZone *string `json:"dnsZone,omitempty"` + DnsZonePartner *string `json:"dnsZonePartner,omitempty"` + ExternalGovernanceStatus *ExternalGovernanceStatus `json:"externalGovernanceStatus,omitempty"` + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + HybridSecondaryUsage *HybridSecondaryUsage `json:"hybridSecondaryUsage,omitempty"` + HybridSecondaryUsageDetected *HybridSecondaryUsageDetected `json:"hybridSecondaryUsageDetected,omitempty"` + InstancePoolId *string `json:"instancePoolId,omitempty"` + IsGeneralPurposeV2 *bool `json:"isGeneralPurposeV2,omitempty"` + KeyId *string `json:"keyId,omitempty"` + LicenseType *ManagedInstanceLicenseType `json:"licenseType,omitempty"` + MaintenanceConfigurationId *string `json:"maintenanceConfigurationId,omitempty"` + ManagedInstanceCreateMode *ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` + MinimalTlsVersion *string `json:"minimalTlsVersion,omitempty"` + PricingModel *FreemiumType `json:"pricingModel,omitempty"` + PrimaryUserAssignedIdentityId *string `json:"primaryUserAssignedIdentityId,omitempty"` + PrivateEndpointConnections *[]ManagedInstancePecProperty `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ProxyOverride *ManagedInstanceProxyOverride `json:"proxyOverride,omitempty"` + PublicDataEndpointEnabled *bool `json:"publicDataEndpointEnabled,omitempty"` + RequestedBackupStorageRedundancy *BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` + RestorePointInTime *string `json:"restorePointInTime,omitempty"` + ServicePrincipal *ServicePrincipal `json:"servicePrincipal,omitempty"` + SourceManagedInstanceId *string `json:"sourceManagedInstanceId,omitempty"` + State *string `json:"state,omitempty"` + StorageIOps *int64 `json:"storageIOps,omitempty"` + StorageSizeInGB *int64 `json:"storageSizeInGB,omitempty"` + StorageThroughputMBps *int64 `json:"storageThroughputMBps,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TimezoneId *string `json:"timezoneId,omitempty"` + TotalMemoryMB *int64 `json:"totalMemoryMB,omitempty"` + VCores *int64 `json:"vCores,omitempty"` + VirtualClusterId *string `json:"virtualClusterId,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *ManagedInstanceProperties) GetCreateTimeAsTime() (*time.Time, error) { + if o.CreateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedInstanceProperties) SetCreateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreateTime = &formatted +} + +func (o *ManagedInstanceProperties) GetRestorePointInTimeAsTime() (*time.Time, error) { + if o.RestorePointInTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RestorePointInTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedInstanceProperties) SetRestorePointInTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RestorePointInTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceupdate.go new file mode 100644 index 000000000000..715d6f5b7842 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_managedinstanceupdate.go @@ -0,0 +1,15 @@ +package managedinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceUpdate struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ManagedInstanceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_outboundenvironmentendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_outboundenvironmentendpoint.go new file mode 100644 index 000000000000..503d29fe9f55 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricinterval.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricinterval.go new file mode 100644 index 000000000000..00c5e8aa6c5b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricinterval.go @@ -0,0 +1,11 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryMetricInterval struct { + ExecutionCount *int64 `json:"executionCount,omitempty"` + IntervalStartTime *string `json:"intervalStartTime,omitempty"` + IntervalType *QueryTimeGrainType `json:"intervalType,omitempty"` + Metrics *[]QueryMetricProperties `json:"metrics,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricproperties.go new file mode 100644 index 000000000000..815192375752 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querymetricproperties.go @@ -0,0 +1,16 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryMetricProperties struct { + Avg *float64 `json:"avg,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Max *float64 `json:"max,omitempty"` + Min *float64 `json:"min,omitempty"` + Name *string `json:"name,omitempty"` + Stdev *float64 `json:"stdev,omitempty"` + Sum *float64 `json:"sum,omitempty"` + Unit *QueryMetricUnitType `json:"unit,omitempty"` + Value *float64 `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querystatisticsproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querystatisticsproperties.go new file mode 100644 index 000000000000..456cf579283d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_querystatisticsproperties.go @@ -0,0 +1,12 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryStatisticsProperties struct { + DatabaseName *string `json:"databaseName,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Intervals *[]QueryMetricInterval `json:"intervals,omitempty"` + QueryId *string `json:"queryId,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultmi.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultmi.go new file mode 100644 index 000000000000..6534ae5095da --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultmi.go @@ -0,0 +1,11 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshExternalGovernanceStatusOperationResultMI struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RefreshExternalGovernanceStatusOperationResultPropertiesMI `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultpropertiesmi.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultpropertiesmi.go new file mode 100644 index 000000000000..7e14768472b7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_refreshexternalgovernancestatusoperationresultpropertiesmi.go @@ -0,0 +1,13 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshExternalGovernanceStatusOperationResultPropertiesMI struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + QueuedTime *string `json:"queuedTime,omitempty"` + RequestId *string `json:"requestId,omitempty"` + RequestType *string `json:"requestType,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_serviceprincipal.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_serviceprincipal.go new file mode 100644 index 000000000000..1e7a6c078872 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_serviceprincipal.go @@ -0,0 +1,11 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePrincipal struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type *ServicePrincipalType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_sku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_sku.go new file mode 100644 index 000000000000..3a2fcc88d159 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_sku.go @@ -0,0 +1,12 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_topqueries.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_topqueries.go new file mode 100644 index 000000000000..ebaf9db44e32 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/model_topqueries.go @@ -0,0 +1,14 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopQueries struct { + AggregationFunction *string `json:"aggregationFunction,omitempty"` + EndTime *string `json:"endTime,omitempty"` + IntervalType *QueryTimeGrainType `json:"intervalType,omitempty"` + NumberOfQueries *int64 `json:"numberOfQueries,omitempty"` + ObservationMetric *string `json:"observationMetric,omitempty"` + Queries *[]QueryStatisticsProperties `json:"queries,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/predicates.go new file mode 100644 index 000000000000..8d70aa8a0614 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/predicates.go @@ -0,0 +1,78 @@ +package managedinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedInstanceOperationPredicate) Matches(input ManagedInstance) 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 OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} + +type TopQueriesOperationPredicate struct { + AggregationFunction *string + EndTime *string + NumberOfQueries *int64 + ObservationMetric *string + StartTime *string +} + +func (p TopQueriesOperationPredicate) Matches(input TopQueries) bool { + + if p.AggregationFunction != nil && (input.AggregationFunction == nil || *p.AggregationFunction != *input.AggregationFunction) { + return false + } + + if p.EndTime != nil && (input.EndTime == nil || *p.EndTime != *input.EndTime) { + return false + } + + if p.NumberOfQueries != nil && (input.NumberOfQueries == nil || *p.NumberOfQueries != *input.NumberOfQueries) { + return false + } + + if p.ObservationMetric != nil && (input.ObservationMetric == nil || *p.ObservationMetric != *input.ObservationMetric) { + return false + } + + if p.StartTime != nil && (input.StartTime == nil || *p.StartTime != *input.StartTime) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/version.go new file mode 100644 index 000000000000..7867a271c1ca --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances/version.go @@ -0,0 +1,12 @@ +package managedinstances + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstances/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/README.md new file mode 100644 index 000000000000..93a00ceadf0e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/README.md @@ -0,0 +1,91 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments` Documentation + +The `managedinstancevulnerabilityassessments` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedinstancevulnerabilityassessments" +``` + + +### Client Initialization + +```go +client := managedinstancevulnerabilityassessments.NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedInstanceVulnerabilityAssessmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedinstancevulnerabilityassessments.ManagedInstanceVulnerabilityAssessment{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedInstanceVulnerabilityAssessmentsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedInstanceVulnerabilityAssessmentsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +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: `ManagedInstanceVulnerabilityAssessmentsClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/client.go new file mode 100644 index 000000000000..9b83141b5c63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/client.go @@ -0,0 +1,26 @@ +package managedinstancevulnerabilityassessments + +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 ManagedInstanceVulnerabilityAssessmentsClient struct { + Client *resourcemanager.Client +} + +func NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedInstanceVulnerabilityAssessmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedinstancevulnerabilityassessments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedInstanceVulnerabilityAssessmentsClient: %+v", err) + } + + return &ManagedInstanceVulnerabilityAssessmentsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_createorupdate.go new file mode 100644 index 000000000000..eee4d2c43187 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_createorupdate.go @@ -0,0 +1,61 @@ +package managedinstancevulnerabilityassessments + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceVulnerabilityAssessment +} + +// CreateOrUpdate ... +func (c ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedInstanceVulnerabilityAssessment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/vulnerabilityAssessments/default", 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 ManagedInstanceVulnerabilityAssessment + 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/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_delete.go new file mode 100644 index 000000000000..2d5068178e1b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_delete.go @@ -0,0 +1,48 @@ +package managedinstancevulnerabilityassessments + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ManagedInstanceVulnerabilityAssessmentsClient) Delete(ctx context.Context, id commonids.SqlManagedInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/vulnerabilityAssessments/default", 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 + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_get.go new file mode 100644 index 000000000000..d5735bb6e64a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_get.go @@ -0,0 +1,56 @@ +package managedinstancevulnerabilityassessments + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedInstanceVulnerabilityAssessment +} + +// Get ... +func (c ManagedInstanceVulnerabilityAssessmentsClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/vulnerabilityAssessments/default", 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 ManagedInstanceVulnerabilityAssessment + 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/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_listbyinstance.go new file mode 100644 index 000000000000..fd8eb23fe585 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/method_listbyinstance.go @@ -0,0 +1,106 @@ +package managedinstancevulnerabilityassessments + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedInstanceVulnerabilityAssessment +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedInstanceVulnerabilityAssessment +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedInstanceVulnerabilityAssessmentsClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/vulnerabilityAssessments", 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 *[]ManagedInstanceVulnerabilityAssessment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedInstanceVulnerabilityAssessmentOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedInstanceVulnerabilityAssessmentOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedInstanceVulnerabilityAssessment, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessment.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessment.go new file mode 100644 index 000000000000..256fafc41673 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessment.go @@ -0,0 +1,11 @@ +package managedinstancevulnerabilityassessments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceVulnerabilityAssessment struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedInstanceVulnerabilityAssessmentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessmentproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessmentproperties.go new file mode 100644 index 000000000000..1828c8de6bea --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_managedinstancevulnerabilityassessmentproperties.go @@ -0,0 +1,11 @@ +package managedinstancevulnerabilityassessments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceVulnerabilityAssessmentProperties struct { + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + StorageContainerPath string `json:"storageContainerPath"` + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_vulnerabilityassessmentrecurringscansproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_vulnerabilityassessmentrecurringscansproperties.go new file mode 100644 index 000000000000..0acb2f6c20f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/model_vulnerabilityassessmentrecurringscansproperties.go @@ -0,0 +1,10 @@ +package managedinstancevulnerabilityassessments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VulnerabilityAssessmentRecurringScansProperties struct { + EmailSubscriptionAdmins *bool `json:"emailSubscriptionAdmins,omitempty"` + Emails *[]string `json:"emails,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/predicates.go new file mode 100644 index 000000000000..74c244d54796 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/predicates.go @@ -0,0 +1,27 @@ +package managedinstancevulnerabilityassessments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedInstanceVulnerabilityAssessmentOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedInstanceVulnerabilityAssessmentOperationPredicate) Matches(input ManagedInstanceVulnerabilityAssessment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/version.go new file mode 100644 index 000000000000..889c9475c591 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments/version.go @@ -0,0 +1,12 @@ +package managedinstancevulnerabilityassessments + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedinstancevulnerabilityassessments/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/README.md new file mode 100644 index 000000000000..746017e06158 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies` Documentation + +The `managedserversecurityalertpolicies` SDK allows for interaction with the Azure Resource Manager Service `sql` (API Version `2023-08-01-preview`). + +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/sql/2023-08-01-preview/managedserversecurityalertpolicies" +``` + + +### Client Initialization + +```go +client := managedserversecurityalertpolicies.NewManagedServerSecurityAlertPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedServerSecurityAlertPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +payload := managedserversecurityalertpolicies.ManagedServerSecurityAlertPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedServerSecurityAlertPoliciesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +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: `ManagedServerSecurityAlertPoliciesClient.ListByInstance` + +```go +ctx := context.TODO() +id := commonids.NewSqlManagedInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedInstanceValue") + +// alternatively `client.ListByInstance(ctx, id)` can be used to do batched pagination +items, err := client.ListByInstanceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/client.go new file mode 100644 index 000000000000..9c1b65773ae7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/client.go @@ -0,0 +1,26 @@ +package managedserversecurityalertpolicies + +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 ManagedServerSecurityAlertPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewManagedServerSecurityAlertPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedServerSecurityAlertPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedserversecurityalertpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedServerSecurityAlertPoliciesClient: %+v", err) + } + + return &ManagedServerSecurityAlertPoliciesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/constants.go new file mode 100644 index 000000000000..7c52e21af30e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/constants.go @@ -0,0 +1,51 @@ +package managedserversecurityalertpolicies + +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 SecurityAlertsPolicyState string + +const ( + SecurityAlertsPolicyStateDisabled SecurityAlertsPolicyState = "Disabled" + SecurityAlertsPolicyStateEnabled SecurityAlertsPolicyState = "Enabled" +) + +func PossibleValuesForSecurityAlertsPolicyState() []string { + return []string{ + string(SecurityAlertsPolicyStateDisabled), + string(SecurityAlertsPolicyStateEnabled), + } +} + +func (s *SecurityAlertsPolicyState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityAlertsPolicyState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityAlertsPolicyState(input string) (*SecurityAlertsPolicyState, error) { + vals := map[string]SecurityAlertsPolicyState{ + "disabled": SecurityAlertsPolicyStateDisabled, + "enabled": SecurityAlertsPolicyStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityAlertsPolicyState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_createorupdate.go new file mode 100644 index 000000000000..57aee0032318 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedserversecurityalertpolicies + +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/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 *ManagedServerSecurityAlertPolicy +} + +// CreateOrUpdate ... +func (c ManagedServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedServerSecurityAlertPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/securityAlertPolicies/default", 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 ManagedServerSecurityAlertPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SqlManagedInstanceId, input ManagedServerSecurityAlertPolicy) 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/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_get.go new file mode 100644 index 000000000000..fb823b520414 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_get.go @@ -0,0 +1,56 @@ +package managedserversecurityalertpolicies + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedServerSecurityAlertPolicy +} + +// Get ... +func (c ManagedServerSecurityAlertPoliciesClient) Get(ctx context.Context, id commonids.SqlManagedInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/securityAlertPolicies/default", 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 ManagedServerSecurityAlertPolicy + 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/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_listbyinstance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_listbyinstance.go new file mode 100644 index 000000000000..d0588ca068fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/method_listbyinstance.go @@ -0,0 +1,106 @@ +package managedserversecurityalertpolicies + +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 ListByInstanceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedServerSecurityAlertPolicy +} + +type ListByInstanceCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedServerSecurityAlertPolicy +} + +type ListByInstanceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByInstanceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByInstance ... +func (c ManagedServerSecurityAlertPoliciesClient) ListByInstance(ctx context.Context, id commonids.SqlManagedInstanceId) (result ListByInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByInstanceCustomPager{}, + Path: fmt.Sprintf("%s/securityAlertPolicies", 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 *[]ManagedServerSecurityAlertPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByInstanceComplete retrieves all the results into a single object +func (c ManagedServerSecurityAlertPoliciesClient) ListByInstanceComplete(ctx context.Context, id commonids.SqlManagedInstanceId) (ListByInstanceCompleteResult, error) { + return c.ListByInstanceCompleteMatchingPredicate(ctx, id, ManagedServerSecurityAlertPolicyOperationPredicate{}) +} + +// ListByInstanceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedServerSecurityAlertPoliciesClient) ListByInstanceCompleteMatchingPredicate(ctx context.Context, id commonids.SqlManagedInstanceId, predicate ManagedServerSecurityAlertPolicyOperationPredicate) (result ListByInstanceCompleteResult, err error) { + items := make([]ManagedServerSecurityAlertPolicy, 0) + + resp, err := c.ListByInstance(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 = ListByInstanceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_managedserversecurityalertpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_managedserversecurityalertpolicy.go new file mode 100644 index 000000000000..a3a3c5f4524e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_managedserversecurityalertpolicy.go @@ -0,0 +1,16 @@ +package managedserversecurityalertpolicies + +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 ManagedServerSecurityAlertPolicy struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_securityalertspolicyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_securityalertspolicyproperties.go new file mode 100644 index 000000000000..7dc643f69f00 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/model_securityalertspolicyproperties.go @@ -0,0 +1,33 @@ +package managedserversecurityalertpolicies + +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 SecurityAlertsPolicyProperties struct { + CreationTime *string `json:"creationTime,omitempty"` + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + RetentionDays *int64 `json:"retentionDays,omitempty"` + State SecurityAlertsPolicyState `json:"state"` + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + StorageEndpoint *string `json:"storageEndpoint,omitempty"` +} + +func (o *SecurityAlertsPolicyProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SecurityAlertsPolicyProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/predicates.go new file mode 100644 index 000000000000..c7d46c58a0f1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/predicates.go @@ -0,0 +1,27 @@ +package managedserversecurityalertpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedServerSecurityAlertPolicyOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedServerSecurityAlertPolicyOperationPredicate) Matches(input ManagedServerSecurityAlertPolicy) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/version.go new file mode 100644 index 000000000000..56787f9ddb9f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies/version.go @@ -0,0 +1,12 @@ +package managedserversecurityalertpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-08-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedserversecurityalertpolicies/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b2adb7eb0d28..47eacad85cee 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1027,6 +1027,17 @@ github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-02-01-preview/server github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-02-01-preview/servers github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-02-01-preview/serversecurityalertpolicies github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-02-01-preview/transparentdataencryptions +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/instancefailovergroups +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedbackupshorttermretentionpolicies +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/manageddatabases +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceadministrators +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceazureadonlyauthentications +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstanceencryptionprotectors +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancekeys +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancelongtermretentionpolicies +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstances +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedinstancevulnerabilityassessments +github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/managedserversecurityalertpolicies github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines diff --git a/website/docs/r/mssql_managed_instance_active_directory_administrator.html.markdown b/website/docs/r/mssql_managed_instance_active_directory_administrator.html.markdown index dee875f7fb03..70174d993b04 100644 --- a/website/docs/r/mssql_managed_instance_active_directory_administrator.html.markdown +++ b/website/docs/r/mssql_managed_instance_active_directory_administrator.html.markdown @@ -105,7 +105,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l * `create` - (Defaults to 30 minutes) Used when creating the SQL Active Directory Administrator. * `update` - (Defaults to 30 minutes) Used when updating the SQL Active Directory Administrator. * `read` - (Defaults to 5 minutes) Used when retrieving the SQL Active Directory Administrator. -* `delete` - (Defaults to 30 minutes) Used when deleting the SQL Active Directory Administrator. +* `delete` - (Defaults to 60 minutes) Used when deleting the SQL Active Directory Administrator. ## Import