From f8090d5614ced065fb6cd1293adde3f14d444142 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Wed, 16 Oct 2024 10:00:00 +0000 Subject: [PATCH] Updating based on cdbd25d76 --- ...model_liftrbasemarketplacedetailsupdate.go | 10 + .../model_liftrbaseofferdetailsupdate.go | 13 + ...el_organizationresourceupdateproperties.go | 1 + ...model_liftrbasemarketplacedetailsupdate.go | 10 + .../model_liftrbaseofferdetailsupdate.go | 14 + ...el_organizationresourceupdateproperties.go | 1 + ...postgresqlv2linkedservicetypeproperties.go | 1 + ..._snowflakelinkedv2servicetypeproperties.go | 3 + ...postgresqlv2linkedservicetypeproperties.go | 1 + ..._snowflakelinkedv2servicetypeproperties.go | 3 + .../pipelines/model_salesforcev2source.go | 1 + .../assetendpointprofiles/README.md | 117 +++ .../assetendpointprofiles/client.go | 26 + .../assetendpointprofiles/constants.go | 104 +++ .../id_assetendpointprofile.go | 130 +++ .../id_assetendpointprofile_test.go | 282 +++++++ .../method_createorreplace.go | 75 ++ .../assetendpointprofiles/method_delete.go | 70 ++ .../assetendpointprofiles/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 106 +++ .../method_listbysubscription.go | 106 +++ .../assetendpointprofiles/method_update.go | 75 ++ .../model_assetendpointprofile.go | 19 + .../model_assetendpointprofileproperties.go | 15 + .../model_assetendpointprofilestatus.go | 8 + .../model_assetendpointprofilestatuserror.go | 9 + .../model_assetendpointprofileupdate.go | 9 + ...el_assetendpointprofileupdateproperties.go | 11 + .../model_authentication.go | 10 + .../model_authenticationupdate.go | 10 + .../model_extendedlocation.go | 9 + .../model_usernamepasswordcredentials.go | 9 + ...model_usernamepasswordcredentialsupdate.go | 9 + .../model_x509credentials.go | 8 + .../model_x509credentialsupdate.go | 8 + .../assetendpointprofiles/predicates.go | 32 + .../assetendpointprofiles/version.go | 10 + .../2024-09-01-preview/assets/README.md | 117 +++ .../2024-09-01-preview/assets/client.go | 26 + .../2024-09-01-preview/assets/constants.go | 192 +++++ .../2024-09-01-preview/assets/id_asset.go | 130 +++ .../assets/id_asset_test.go | 282 +++++++ .../assets/method_createorreplace.go | 75 ++ .../assets/method_delete.go | 70 ++ .../2024-09-01-preview/assets/method_get.go | 53 ++ .../assets/method_listbyresourcegroup.go | 106 +++ .../assets/method_listbysubscription.go | 106 +++ .../assets/method_update.go | 75 ++ .../2024-09-01-preview/assets/model_asset.go | 19 + .../assets/model_assetproperties.go | 31 + .../assets/model_assetstatus.go | 11 + .../assets/model_assetstatusdataset.go | 9 + .../assets/model_assetstatuserror.go | 9 + .../assets/model_assetstatusevent.go | 9 + .../assets/model_assetupdate.go | 9 + .../assets/model_assetupdateproperties.go | 24 + .../assets/model_datapoint.go | 11 + .../assets/model_dataset.go | 11 + .../2024-09-01-preview/assets/model_event.go | 12 + .../assets/model_extendedlocation.go | 9 + .../assets/model_messageschemareference.go | 10 + .../2024-09-01-preview/assets/model_topic.go | 9 + .../assets/model_topicupdate.go | 9 + .../2024-09-01-preview/assets/predicates.go | 32 + .../2024-09-01-preview/assets/version.go | 10 + .../billingcontainers/README.md | 54 ++ .../billingcontainers/client.go | 26 + .../billingcontainers/constants.go | 60 ++ .../billingcontainers/id_billingcontainer.go | 121 +++ .../id_billingcontainer_test.go | 237 ++++++ .../billingcontainers/method_get.go | 53 ++ .../method_listbysubscription.go | 106 +++ .../model_billingcontainer.go | 17 + .../model_billingcontainerproperties.go | 8 + .../billingcontainers/predicates.go | 32 + .../billingcontainers/version.go | 10 + .../2024-09-01-preview/client.go | 91 ++ .../discoveredassetendpointprofiles/README.md | 117 +++ .../discoveredassetendpointprofiles/client.go | 26 + .../constants.go | 104 +++ .../id_discoveredassetendpointprofile.go | 130 +++ .../id_discoveredassetendpointprofile_test.go | 282 +++++++ .../method_createorreplace.go | 75 ++ .../method_delete.go | 70 ++ .../method_get.go | 53 ++ .../method_listbyresourcegroup.go | 106 +++ .../method_listbysubscription.go | 106 +++ .../method_update.go | 75 ++ .../model_discoveredassetendpointprofile.go | 19 + ...iscoveredassetendpointprofileproperties.go | 14 + ...el_discoveredassetendpointprofileupdate.go | 9 + ...redassetendpointprofileupdateproperties.go | 13 + .../model_extendedlocation.go | 9 + .../predicates.go | 32 + .../version.go | 10 + .../discoveredassets/README.md | 117 +++ .../discoveredassets/client.go | 26 + .../discoveredassets/constants.go | 101 +++ .../discoveredassets/id_discoveredasset.go | 130 +++ .../id_discoveredasset_test.go | 282 +++++++ .../method_createorreplace.go | 75 ++ .../discoveredassets/method_delete.go | 70 ++ .../discoveredassets/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 106 +++ .../method_listbysubscription.go | 106 +++ .../discoveredassets/method_update.go | 75 ++ .../discoveredassets/model_discoveredasset.go | 19 + .../model_discoveredassetproperties.go | 24 + .../model_discoveredassetupdate.go | 9 + .../model_discoveredassetupdateproperties.go | 22 + .../model_discovereddatapoint.go | 29 + .../model_discovereddataset.go | 11 + .../discoveredassets/model_discoveredevent.go | 30 + .../model_extendedlocation.go | 9 + .../discoveredassets/model_topic.go | 9 + .../discoveredassets/model_topicupdate.go | 9 + .../discoveredassets/predicates.go | 32 + .../discoveredassets/version.go | 10 + .../schemaregistries/README.md | 117 +++ .../schemaregistries/client.go | 26 + .../schemaregistries/constants.go | 60 ++ .../schemaregistries/id_schemaregistry.go | 130 +++ .../id_schemaregistry_test.go | 282 +++++++ .../method_createorreplace.go | 75 ++ .../schemaregistries/method_delete.go | 70 ++ .../schemaregistries/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 106 +++ .../method_listbysubscription.go | 106 +++ .../schemaregistries/method_update.go | 75 ++ .../schemaregistries/model_schemaregistry.go | 20 + .../model_schemaregistryproperties.go | 13 + .../model_schemaregistryupdate.go | 14 + .../model_schemaregistryupdateproperties.go | 9 + .../schemaregistries/predicates.go | 32 + .../schemaregistries/version.go | 10 + .../2024-09-01-preview/schemas/README.md | 90 ++ .../2024-09-01-preview/schemas/client.go | 26 + .../2024-09-01-preview/schemas/constants.go | 139 +++ .../2024-09-01-preview/schemas/id_schema.go | 139 +++ .../schemas/id_schema_test.go | 327 ++++++++ .../schemas/id_schemaregistry.go | 130 +++ .../schemas/id_schemaregistry_test.go | 282 +++++++ .../schemas/method_createorreplace.go | 58 ++ .../schemas/method_delete.go | 47 ++ .../2024-09-01-preview/schemas/method_get.go | 53 ++ .../schemas/method_listbyschemaregistry.go | 105 +++ .../schemas/model_schema.go | 16 + .../schemas/model_schemaproperties.go | 14 + .../2024-09-01-preview/schemas/predicates.go | 27 + .../2024-09-01-preview/schemas/version.go | 10 + .../schemaversions/README.md | 90 ++ .../schemaversions/client.go | 26 + .../schemaversions/constants.go | 60 ++ .../schemaversions/id_schema.go | 139 +++ .../schemaversions/id_schema_test.go | 327 ++++++++ .../schemaversions/id_schemaversion.go | 148 ++++ .../schemaversions/id_schemaversion_test.go | 372 ++++++++ .../schemaversions/method_createorreplace.go | 58 ++ .../schemaversions/method_delete.go | 47 ++ .../schemaversions/method_get.go | 53 ++ .../schemaversions/method_listbyschema.go | 105 +++ .../schemaversions/model_schemaversion.go | 16 + .../model_schemaversionproperties.go | 12 + .../schemaversions/predicates.go | 27 + .../schemaversions/version.go | 10 + .../availableservicetiers/README.md | 36 + .../availableservicetiers/client.go | 26 + .../availableservicetiers/constants.go | 66 ++ .../availableservicetiers/id_workspace.go | 130 +++ .../id_workspace_test.go | 282 +++++++ .../method_listbyworkspace.go | 54 ++ .../model_availableservicetier.go | 14 + .../availableservicetiers/version.go | 10 + .../operationalinsights/2023-09-01/client.go | 116 ++- .../2023-09-01/clusters/README.md | 117 +++ .../2023-09-01/clusters/client.go | 26 + .../2023-09-01/clusters/constants.go | 177 ++++ .../2023-09-01/clusters/id_cluster.go | 130 +++ .../2023-09-01/clusters/id_cluster_test.go | 282 +++++++ .../clusters/method_createorupdate.go | 76 ++ .../2023-09-01/clusters/method_delete.go | 71 ++ .../2023-09-01/clusters/method_get.go | 53 ++ .../2023-09-01/clusters/method_list.go | 106 +++ .../clusters/method_listbyresourcegroup.go | 106 +++ .../2023-09-01/clusters/method_update.go | 74 ++ .../clusters/model_associatedworkspace.go | 11 + .../model_capacityreservationproperties.go | 9 + .../2023-09-01/clusters/model_cluster.go | 19 + .../2023-09-01/clusters/model_clusterpatch.go | 15 + .../clusters/model_clusterpatchproperties.go | 9 + .../clusters/model_clusterproperties.go | 17 + .../2023-09-01/clusters/model_clustersku.go | 9 + .../clusters/model_keyvaultproperties.go | 11 + .../2023-09-01/clusters/predicates.go | 32 + .../2023-09-01/clusters/version.go | 10 + .../2023-09-01/dataexport/README.md | 89 ++ .../2023-09-01/dataexport/client.go | 26 + .../2023-09-01/dataexport/constants.go | 51 ++ .../2023-09-01/dataexport/id_dataexport.go | 139 +++ .../dataexport/id_dataexport_test.go | 327 ++++++++ .../2023-09-01/dataexport/id_workspace.go | 130 +++ .../dataexport/id_workspace_test.go | 282 +++++++ .../dataexport/method_createorupdate.go | 58 ++ .../2023-09-01/dataexport/method_delete.go | 46 + .../2023-09-01/dataexport/method_get.go | 53 ++ .../dataexport/method_listbyworkspace.go | 54 ++ .../2023-09-01/dataexport/model_dataexport.go | 11 + .../dataexport/model_dataexportlistresult.go | 8 + .../dataexport/model_dataexportproperties.go | 13 + .../dataexport/model_destination.go | 10 + .../dataexport/model_destinationmetadata.go | 8 + .../2023-09-01/dataexport/version.go | 10 + .../2023-09-01/datasources/README.md | 90 ++ .../2023-09-01/datasources/client.go | 26 + .../2023-09-01/datasources/constants.go | 144 ++++ .../2023-09-01/datasources/id_datasource.go | 139 +++ .../datasources/id_datasource_test.go | 327 ++++++++ .../2023-09-01/datasources/id_workspace.go | 130 +++ .../datasources/id_workspace_test.go | 282 +++++++ .../datasources/method_createorupdate.go | 58 ++ .../2023-09-01/datasources/method_delete.go | 47 ++ .../2023-09-01/datasources/method_get.go | 53 ++ .../datasources/method_listbyworkspace.go | 134 +++ .../datasources/model_datasource.go | 14 + .../2023-09-01/datasources/predicates.go | 37 + .../2023-09-01/datasources/version.go | 10 + .../2023-09-01/intelligencepacks/README.md | 68 ++ .../2023-09-01/intelligencepacks/client.go | 26 + .../intelligencepacks/id_intelligencepack.go | 139 +++ .../id_intelligencepack_test.go | 327 ++++++++ .../intelligencepacks/id_workspace.go | 130 +++ .../intelligencepacks/id_workspace_test.go | 282 +++++++ .../intelligencepacks/method_disable.go | 47 ++ .../intelligencepacks/method_enable.go | 47 ++ .../intelligencepacks/method_list.go | 54 ++ .../model_intelligencepack.go | 10 + .../2023-09-01/intelligencepacks/version.go | 10 + .../2023-09-01/linkedservices/README.md | 81 ++ .../2023-09-01/linkedservices/client.go | 26 + .../2023-09-01/linkedservices/constants.go | 57 ++ .../linkedservices/id_linkedservice.go | 139 +++ .../linkedservices/id_linkedservice_test.go | 327 ++++++++ .../2023-09-01/linkedservices/id_workspace.go | 130 +++ .../linkedservices/id_workspace_test.go | 282 +++++++ .../linkedservices/method_createorupdate.go | 76 ++ .../linkedservices/method_delete.go | 72 ++ .../2023-09-01/linkedservices/method_get.go | 53 ++ .../linkedservices/method_listbyworkspace.go | 54 ++ .../linkedservices/model_linkedservice.go | 12 + .../model_linkedservicelistresult.go | 8 + .../model_linkedserviceproperties.go | 10 + .../2023-09-01/linkedservices/version.go | 10 + .../linkedstorageaccounts/README.md | 89 ++ .../linkedstorageaccounts/client.go | 26 + .../linkedstorageaccounts/constants.go | 60 ++ .../id_datasourcetype.go | 147 ++++ .../id_datasourcetype_test.go | 327 ++++++++ .../linkedstorageaccounts/id_workspace.go | 130 +++ .../id_workspace_test.go | 282 +++++++ .../method_createorupdate.go | 57 ++ .../linkedstorageaccounts/method_delete.go | 46 + .../linkedstorageaccounts/method_get.go | 53 ++ .../method_listbyworkspace.go | 54 ++ .../model_linkedstorageaccountslistresult.go | 8 + .../model_linkedstorageaccountsproperties.go | 9 + .../model_linkedstorageaccountsresource.go | 11 + .../linkedstorageaccounts/version.go | 10 + .../2023-09-01/querypackqueries/README.md | 133 +++ .../2023-09-01/querypackqueries/client.go | 26 + .../2023-09-01/querypackqueries/id_query.go | 139 +++ .../querypackqueries/id_query_test.go | 327 ++++++++ .../querypackqueries/id_querypack.go | 130 +++ .../querypackqueries/id_querypack_test.go | 282 +++++++ .../querypackqueries/method_queriesdelete.go | 47 ++ .../querypackqueries/method_queriesget.go | 53 ++ .../querypackqueries/method_querieslist.go | 138 +++ .../querypackqueries/method_queriesput.go | 57 ++ .../querypackqueries/method_queriessearch.go | 138 +++ .../querypackqueries/method_queriesupdate.go | 57 ++ .../model_loganalyticsquerypackquery.go | 16 + ...el_loganalyticsquerypackqueryproperties.go | 47 ++ ...nalyticsquerypackquerypropertiesrelated.go | 10 + ...analyticsquerypackquerysearchproperties.go | 9 + ...csquerypackquerysearchpropertiesrelated.go | 10 + .../2023-09-01/querypackqueries/predicates.go | 27 + .../2023-09-01/querypackqueries/version.go | 10 + .../2023-09-01/querypacks/README.md | 150 ++++ .../2023-09-01/querypacks/client.go | 26 + .../2023-09-01/querypacks/id_querypack.go | 130 +++ .../querypacks/id_querypack_test.go | 282 +++++++ .../querypacks/method_createorupdate.go | 57 ++ .../method_createorupdatewithoutname.go | 59 ++ .../2023-09-01/querypacks/method_delete.go | 47 ++ .../2023-09-01/querypacks/method_get.go | 53 ++ .../2023-09-01/querypacks/method_list.go | 106 +++ .../querypacks/method_listbyresourcegroup.go | 106 +++ .../querypacks/method_updatetags.go | 57 ++ .../querypacks/model_loganalyticsquerypack.go | 18 + .../model_loganalyticsquerypackproperties.go | 41 + .../querypacks/model_tagsresource.go | 8 + .../2023-09-01/querypacks/predicates.go | 32 + .../2023-09-01/querypacks/version.go | 10 + .../2023-09-01/savedsearches/README.md | 89 ++ .../2023-09-01/savedsearches/client.go | 26 + .../savedsearches/id_savedsearch.go | 139 +++ .../savedsearches/id_savedsearch_test.go | 327 ++++++++ .../2023-09-01/savedsearches/id_workspace.go | 130 +++ .../savedsearches/id_workspace_test.go | 282 +++++++ .../savedsearches/method_createorupdate.go | 57 ++ .../2023-09-01/savedsearches/method_delete.go | 46 + .../2023-09-01/savedsearches/method_get.go | 53 ++ .../savedsearches/method_listbyworkspace.go | 54 ++ .../savedsearches/model_savedsearch.go | 12 + .../model_savedsearcheslistresult.go | 8 + .../model_savedsearchproperties.go | 14 + .../2023-09-01/savedsearches/model_tag.go | 9 + .../2023-09-01/savedsearches/version.go | 10 + .../2023-09-01/storageinsights/README.md | 90 ++ .../2023-09-01/storageinsights/client.go | 26 + .../2023-09-01/storageinsights/constants.go | 51 ++ .../id_storageinsightconfig.go | 139 +++ .../id_storageinsightconfig_test.go | 327 ++++++++ .../storageinsights/id_workspace.go | 130 +++ .../storageinsights/id_workspace_test.go | 282 +++++++ ...hod_storageinsightconfigscreateorupdate.go | 58 ++ .../method_storageinsightconfigsdelete.go | 47 ++ .../method_storageinsightconfigsget.go | 53 ++ ...od_storageinsightconfigslistbyworkspace.go | 105 +++ .../storageinsights/model_storageaccount.go | 9 + .../storageinsights/model_storageinsight.go | 13 + .../model_storageinsightproperties.go | 11 + .../model_storageinsightstatus.go | 9 + .../2023-09-01/storageinsights/predicates.go | 32 + .../2023-09-01/storageinsights/version.go | 10 + .../2023-09-01/tables/README.md | 130 +++ .../2023-09-01/tables/client.go | 26 + .../2023-09-01/tables/constants.go | 336 ++++++++ .../2023-09-01/tables/id_table.go | 139 +++ .../2023-09-01/tables/id_table_test.go | 327 ++++++++ .../2023-09-01/tables/id_workspace.go | 130 +++ .../2023-09-01/tables/id_workspace_test.go | 282 +++++++ .../2023-09-01/tables/method_cancelsearch.go | 47 ++ .../tables/method_createorupdate.go | 75 ++ .../2023-09-01/tables/method_delete.go | 71 ++ .../2023-09-01/tables/method_get.go | 53 ++ .../tables/method_listbyworkspace.go | 54 ++ .../2023-09-01/tables/method_migrate.go | 47 ++ .../2023-09-01/tables/method_update.go | 75 ++ .../2023-09-01/tables/model_column.go | 14 + .../2023-09-01/tables/model_restoredlogs.go | 41 + .../tables/model_resultstatistics.go | 10 + .../2023-09-01/tables/model_schema.go | 18 + .../2023-09-01/tables/model_searchresults.go | 44 + .../2023-09-01/tables/model_table.go | 16 + .../tables/model_tableproperties.go | 19 + .../tables/model_tableslistresult.go | 8 + .../2023-09-01/tables/version.go | 10 + .../2023-09-01/workspaces/README.md | 181 ++++ .../2023-09-01/workspaces/constants.go | 82 ++ .../2023-09-01/workspaces/id_gateway.go | 139 +++ .../2023-09-01/workspaces/id_gateway_test.go | 327 ++++++++ .../workspaces/id_intelligencepack.go | 139 +++ .../workspaces/id_intelligencepack_test.go | 327 ++++++++ .../2023-09-01/workspaces/id_operation.go | 139 +++ .../workspaces/id_operation_test.go | 327 ++++++++ .../workspaces/method_gatewaysdelete.go | 46 + .../method_intelligencepacksdisable.go | 47 ++ .../method_intelligencepacksenable.go | 47 ++ .../method_intelligencepackslist.go | 54 ++ .../workspaces/method_managementgroupslist.go | 54 ++ .../2023-09-01/workspaces/method_schemaget.go | 54 ++ .../method_sharedkeysgetsharedkeys.go | 54 ++ .../workspaces/method_sharedkeysregenerate.go | 54 ++ .../workspaces/method_usageslist.go | 54 ++ .../method_workspacepurgegetpurgestatus.go | 53 ++ .../workspaces/method_workspacepurgepurge.go | 58 ++ .../workspaces/model_coresummary.go | 9 + .../workspaces/model_intelligencepack.go | 10 + .../workspaces/model_managementgroup.go | 8 + .../model_managementgroupproperties.go | 45 + .../2023-09-01/workspaces/model_metricname.go | 9 + .../model_searchgetschemaresponse.go | 9 + .../workspaces/model_searchmetadata.go | 54 ++ .../workspaces/model_searchmetadataschema.go | 9 + .../workspaces/model_searchschemavalue.go | 14 + .../2023-09-01/workspaces/model_searchsort.go | 9 + .../2023-09-01/workspaces/model_sharedkeys.go | 9 + .../workspaces/model_usagemetric.go | 31 + ...del_workspacelistmanagementgroupsresult.go | 8 + .../model_workspacelistusagesresult.go | 8 + .../workspaces/model_workspacepurgebody.go | 9 + .../model_workspacepurgebodyfilters.go | 11 + .../model_workspacepurgeresponse.go | 8 + .../model_workspacepurgestatusresponse.go | 8 + ...utonomousdatabasecharactersetproperties.go | 2 +- ...sdatabasenationalcharactersetproperties.go | 2 +- .../model_autonomousdbversionproperties.go | 2 +- .../dbnodes/model_dbnodeproperties.go | 17 +- .../model_dbsystemshapeproperties.go | 2 +- .../model_dnsprivateviewproperties.go | 30 +- .../model_dnsprivatezoneproperties.go | 27 +- .../giversions/model_giversionproperties.go | 2 +- .../model_systemversionproperties.go | 2 +- .../2024-06-01-preview/adminkeys/README.md | 52 ++ .../2024-06-01-preview/adminkeys/client.go | 26 + .../2024-06-01-preview/adminkeys/constants.go | 51 ++ .../adminkeys/id_keykind.go | 147 ++++ .../adminkeys/id_keykind_test.go | 327 ++++++++ .../adminkeys/id_searchservice.go | 130 +++ .../adminkeys/id_searchservice_test.go | 282 +++++++ .../adminkeys/method_get.go | 83 ++ .../adminkeys/method_regenerate.go | 83 ++ .../adminkeys/model_adminkeyresult.go | 9 + .../2024-06-01-preview/adminkeys/version.go | 10 + .../search/2024-06-01-preview/client.go | 91 ++ .../README.md | 65 ++ .../client.go | 26 + ...d_networksecurityperimeterconfiguration.go | 139 +++ ...worksecurityperimeterconfiguration_test.go | 327 ++++++++ .../id_searchservice.go | 130 +++ .../id_searchservice_test.go | 282 +++++++ .../method_get.go | 53 ++ .../method_listbyservice.go | 105 +++ .../method_reconcile.go | 69 ++ ...l_networksecurityperimeterconfiguration.go | 11 + ...ecurityperimeterconfigurationproperties.go | 12 + .../model_nspconfigaccessrule.go | 9 + .../model_nspconfigaccessruleproperties.go | 12 + .../model_nspconfigassociation.go | 9 + ...l_nspconfignetworksecurityperimeterrule.go | 10 + .../model_nspconfigperimeter.go | 10 + .../model_nspconfigprofile.go | 10 + .../model_nspprovisioningissue.go | 9 + .../model_nspprovisioningissueproperties.go | 12 + .../predicates.go | 27 + .../version.go | 10 + .../privateendpointconnections/README.md | 90 ++ .../privateendpointconnections/client.go | 26 + .../privateendpointconnections/constants.go | 110 +++ .../id_privateendpointconnection.go | 139 +++ .../id_privateendpointconnection_test.go | 327 ++++++++ .../id_searchservice.go | 130 +++ .../id_searchservice_test.go | 282 +++++++ .../method_delete.go | 83 ++ .../privateendpointconnections/method_get.go | 83 ++ .../method_listbyservice.go | 134 +++ .../method_update.go | 87 ++ .../model_privateendpointconnection.go | 11 + ...del_privateendpointconnectionproperties.go | 11 + ...ointconnectionpropertiesprivateendpoint.go | 8 + ...ertiesprivatelinkserviceconnectionstate.go | 10 + .../privateendpointconnections/predicates.go | 27 + .../privateendpointconnections/version.go | 10 + .../privatelinkresources/README.md | 36 + .../privatelinkresources/client.go | 26 + .../privatelinkresources/id_searchservice.go | 130 +++ .../id_searchservice_test.go | 282 +++++++ .../method_listsupported.go | 83 ++ .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 11 + .../model_privatelinkresourcesresult.go | 8 + ..._shareableprivatelinkresourceproperties.go | 10 + .../model_shareableprivatelinkresourcetype.go | 9 + .../privatelinkresources/version.go | 10 + .../2024-06-01-preview/querykeys/README.md | 69 ++ .../2024-06-01-preview/querykeys/client.go | 26 + .../querykeys/id_createquerykey.go | 139 +++ .../querykeys/id_createquerykey_test.go | 327 ++++++++ .../querykeys/id_deletequerykey.go | 139 +++ .../querykeys/id_deletequerykey_test.go | 327 ++++++++ .../querykeys/id_searchservice.go | 130 +++ .../querykeys/id_searchservice_test.go | 282 +++++++ .../querykeys/method_create.go | 83 ++ .../querykeys/method_delete.go | 77 ++ .../querykeys/method_listbysearchservice.go | 134 +++ .../querykeys/model_querykey.go | 9 + .../querykeys/predicates.go | 22 + .../2024-06-01-preview/querykeys/version.go | 10 + .../2024-06-01-preview/services/README.md | 146 ++++ .../2024-06-01-preview/services/client.go | 26 + .../2024-06-01-preview/services/constants.go | 776 +++++++++++++++++ .../services/id_searchservice.go | 130 +++ .../services/id_searchservice_test.go | 282 +++++++ .../services/method_checknameavailability.go | 88 ++ .../services/method_createorupdate.go | 104 +++ .../services/method_delete.go | 77 ++ .../2024-06-01-preview/services/method_get.go | 83 ++ .../services/method_listbyresourcegroup.go | 135 +++ .../services/method_listbysubscription.go | 135 +++ .../services/method_update.go | 87 ++ .../model_checknameavailabilityinput.go | 9 + .../model_checknameavailabilityoutput.go | 10 + .../model_dataplaneaadorapikeyauthoption.go | 8 + .../services/model_dataplaneauthoptions.go | 9 + .../services/model_encryptionwithcmk.go | 9 + .../services/model_iprule.go | 8 + .../services/model_networkruleset.go | 9 + .../model_privateendpointconnection.go | 11 + ...del_privateendpointconnectionproperties.go | 11 + ...ointconnectionpropertiesprivateendpoint.go | 8 + ...ertiesprivatelinkserviceconnectionstate.go | 10 + .../services/model_searchservice.go | 19 + .../services/model_searchserviceproperties.go | 23 + .../services/model_searchserviceupdate.go | 19 + .../model_sharedprivatelinkresource.go | 11 + ...del_sharedprivatelinkresourceproperties.go | 13 + .../2024-06-01-preview/services/model_sku.go | 8 + .../2024-06-01-preview/services/predicates.go | 32 + .../2024-06-01-preview/services/version.go | 10 + .../sharedprivatelinkresources/README.md | 82 ++ .../sharedprivatelinkresources/client.go | 26 + .../sharedprivatelinkresources/constants.go | 107 +++ .../id_searchservice.go | 130 +++ .../id_searchservice_test.go | 282 +++++++ .../id_sharedprivatelinkresource.go | 139 +++ .../id_sharedprivatelinkresource_test.go | 327 ++++++++ .../method_createorupdate.go | 104 +++ .../method_delete.go | 99 +++ .../sharedprivatelinkresources/method_get.go | 83 ++ .../method_listbyservice.go | 134 +++ .../model_sharedprivatelinkresource.go | 11 + ...del_sharedprivatelinkresourceproperties.go | 13 + .../sharedprivatelinkresources/predicates.go | 27 + .../sharedprivatelinkresources/version.go | 10 + .../2024-06-01-preview/usages/README.md | 53 ++ .../2024-06-01-preview/usages/client.go | 26 + .../2024-06-01-preview/usages/id_location.go | 121 +++ .../usages/id_location_test.go | 237 ++++++ .../2024-06-01-preview/usages/id_usage.go | 130 +++ .../usages/id_usage_test.go | 282 +++++++ .../usages/method_listbysubscription.go | 134 +++ .../usages/method_usagebysubscriptionsku.go | 83 ++ .../usages/model_quotausageresult.go | 12 + .../usages/model_quotausageresultname.go | 9 + .../2024-06-01-preview/usages/predicates.go | 32 + .../2024-06-01-preview/usages/version.go | 10 + .../model_siteproperties.go | 1 + .../appserviceplans/model_siteproperties.go | 1 + .../webapps/model_siteproperties.go | 1 + .../workloads/2024-09-01/client.go | 55 ++ .../sapapplicationserverinstances/README.md | 137 +++ .../sapapplicationserverinstances/client.go | 26 + .../constants.go | 210 +++++ .../id_applicationinstance.go | 139 +++ .../id_applicationinstance_test.go | 327 ++++++++ .../id_sapvirtualinstance.go | 130 +++ .../id_sapvirtualinstance_test.go | 282 +++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../method_get.go | 53 ++ .../method_list.go | 105 +++ .../method_start.go | 75 ++ .../method_stop.go | 75 ++ .../method_update.go | 57 ++ .../model_applicationservervmdetails.go | 10 + .../model_erroradditionalinfo.go | 9 + .../model_errordefinition.go | 10 + .../model_errordetail.go | 12 + .../model_loadbalancerdetails.go | 8 + .../model_operationstatusresult.go | 46 + .../model_sapapplicationserverinstance.go | 18 + .../model_sapapplicationserverproperties.go | 23 + .../model_sapvirtualinstanceerror.go | 8 + .../model_startrequest.go | 8 + .../model_stoprequest.go | 9 + .../model_storageinformation.go | 8 + ...del_updatesapapplicationinstancerequest.go | 8 + .../predicates.go | 32 + .../sapapplicationserverinstances/version.go | 10 + .../sapcentralserverinstances/README.md | 137 +++ .../sapcentralserverinstances/client.go | 26 + .../sapcentralserverinstances/constants.go | 263 ++++++ .../id_centralinstance.go | 139 +++ .../id_centralinstance_test.go | 327 ++++++++ .../id_sapvirtualinstance.go | 130 +++ .../id_sapvirtualinstance_test.go | 282 +++++++ .../method_create.go | 75 ++ .../method_delete.go | 70 ++ .../sapcentralserverinstances/method_get.go | 53 ++ .../sapcentralserverinstances/method_list.go | 105 +++ .../sapcentralserverinstances/method_start.go | 75 ++ .../sapcentralserverinstances/method_stop.go | 75 ++ .../method_update.go | 57 ++ .../model_centralservervmdetails.go | 10 + ...odel_enqueuereplicationserverproperties.go | 14 + .../model_enqueueserverproperties.go | 11 + .../model_erroradditionalinfo.go | 9 + .../model_errordefinition.go | 10 + .../model_errordetail.go | 12 + .../model_gatewayserverproperties.go | 9 + .../model_loadbalancerdetails.go | 8 + .../model_messageserverproperties.go | 14 + .../model_operationstatusresult.go | 46 + .../model_sapcentralserverinstance.go | 18 + .../model_sapcentralserverproperties.go | 21 + .../model_sapvirtualinstanceerror.go | 8 + .../model_startrequest.go | 8 + .../model_stoprequest.go | 9 + .../model_storageinformation.go | 8 + .../model_updatesapcentralinstancerequest.go | 8 + .../sapcentralserverinstances/predicates.go | 32 + .../sapcentralserverinstances/version.go | 10 + .../2024-09-01/sapdatabaseinstances/README.md | 137 +++ .../2024-09-01/sapdatabaseinstances/client.go | 26 + .../sapdatabaseinstances/constants.go | 119 +++ .../id_databaseinstance.go | 139 +++ .../id_databaseinstance_test.go | 327 ++++++++ .../id_sapvirtualinstance.go | 130 +++ .../id_sapvirtualinstance_test.go | 282 +++++++ .../sapdatabaseinstances/method_create.go | 75 ++ .../sapdatabaseinstances/method_delete.go | 70 ++ .../sapdatabaseinstances/method_get.go | 53 ++ .../sapdatabaseinstances/method_list.go | 105 +++ .../sapdatabaseinstances/method_start.go | 75 ++ .../sapdatabaseinstances/method_stop.go | 75 ++ .../sapdatabaseinstances/method_update.go | 57 ++ .../model_databasevmdetails.go | 10 + .../model_erroradditionalinfo.go | 9 + .../model_errordefinition.go | 10 + .../sapdatabaseinstances/model_errordetail.go | 12 + .../model_loadbalancerdetails.go | 8 + .../model_operationstatusresult.go | 46 + .../model_sapdatabaseinstance.go | 18 + .../model_sapdatabaseproperties.go | 16 + .../model_sapvirtualinstanceerror.go | 8 + .../model_startrequest.go | 8 + .../sapdatabaseinstances/model_stoprequest.go | 9 + .../model_storageinformation.go | 8 + .../model_updatesapdatabaseinstancerequest.go | 8 + .../sapdatabaseinstances/predicates.go | 32 + .../sapdatabaseinstances/version.go | 10 + .../2024-09-01/sapvirtualinstances/README.md | 235 ++++++ .../2024-09-01/sapvirtualinstances/client.go | 26 + .../sapvirtualinstances/constants.go | 794 ++++++++++++++++++ .../sapvirtualinstances/id_location.go | 121 +++ .../sapvirtualinstances/id_location_test.go | 237 ++++++ .../id_sapvirtualinstance.go | 130 +++ .../id_sapvirtualinstance_test.go | 282 +++++++ .../sapvirtualinstances/method_create.go | 75 ++ .../sapvirtualinstances/method_delete.go | 70 ++ .../sapvirtualinstances/method_get.go | 53 ++ .../method_invokeavailabilityzonedetails.go | 58 ++ .../method_invokediskconfigurations.go | 58 ++ .../method_invokesapsupportedsku.go | 58 ++ .../method_invokesizingrecommendations.go | 63 ++ .../method_listbyresourcegroup.go | 106 +++ .../method_listbysubscription.go | 106 +++ .../sapvirtualinstances/method_start.go | 75 ++ .../sapvirtualinstances/method_stop.go | 75 ++ .../sapvirtualinstances/method_update.go | 75 ++ .../model_applicationserverconfiguration.go | 10 + ...odel_applicationserverfullresourcenames.go | 9 + .../model_centralserverconfiguration.go | 10 + .../model_centralserverfullresourcenames.go | 10 + ...el_createandmountfileshareconfiguration.go | 51 ++ .../model_databaseconfiguration.go | 12 + .../model_databaseserverfullresourcenames.go | 10 + .../model_deployervmpackages.go | 9 + .../model_deploymentconfiguration.go | 90 ++ .../model_deploymentwithosconfiguration.go | 93 ++ .../model_discoveryconfiguration.go | 52 ++ .../model_diskconfiguration.go | 8 + .../sapvirtualinstances/model_diskdetails.go | 14 + .../sapvirtualinstances/model_disksku.go | 8 + .../model_diskvolumeconfiguration.go | 10 + .../model_erroradditionalinfo.go | 9 + .../model_errordefinition.go | 10 + .../sapvirtualinstances/model_errordetail.go | 12 + ...ternalinstallationsoftwareconfiguration.go | 50 ++ .../model_fileshareconfiguration.go | 91 ++ .../model_highavailabilityconfiguration.go | 8 + ...l_highavailabilitysoftwareconfiguration.go | 9 + .../model_imagereference.go | 12 + .../model_infrastructureconfiguration.go | 84 ++ .../model_linuxconfiguration.go | 52 ++ .../model_loadbalancerresourcenames.go | 11 + .../model_managedrgconfiguration.go | 8 + .../model_mountfileshareconfiguration.go | 51 ++ .../model_networkconfiguration.go | 8 + .../model_networkinterfaceresourcenames.go | 8 + .../model_operationstatusresult.go | 46 + .../model_osconfiguration.go | 83 ++ .../sapvirtualinstances/model_osprofile.go | 45 + .../model_ossapconfiguration.go | 9 + ...model_sapavailabilityzonedetailsrequest.go | 10 + .../model_sapavailabilityzonedetailsresult.go | 8 + .../model_sapavailabilityzonepair.go | 9 + .../model_sapconfiguration.go | 91 ++ .../model_sapdiskconfiguration.go | 9 + .../model_sapdiskconfigurationsrequest.go | 13 + .../model_sapdiskconfigurationsresult.go | 8 + ...allwithoutosconfigsoftwareconfiguration.go | 53 ++ .../model_sapsizingrecommendationrequest.go | 16 + .../model_sapsizingrecommendationresult.go | 83 ++ .../model_sapsupportedresourceskusresult.go | 8 + .../model_sapsupportedsku.go | 10 + .../model_sapsupportedskusrequest.go | 13 + .../model_sapvirtualinstance.go | 20 + .../model_sapvirtualinstanceerror.go | 8 + .../model_sapvirtualinstanceproperties.go | 66 ++ ...l_serviceinitiatedsoftwareconfiguration.go | 55 ++ .../model_sharedstorageresourcenames.go | 9 + .../model_singleserverconfiguration.go | 97 +++ .../model_singleservercustomresourcenames.go | 75 ++ .../model_singleserverfullresourcenames.go | 50 ++ .../model_singleserverrecommendationresult.go | 50 ++ .../model_skipfileshareconfiguration.go | 49 ++ .../model_softwareconfiguration.go | 91 ++ .../model_sshconfiguration.go | 8 + .../sapvirtualinstances/model_sshkeypair.go | 9 + .../sapvirtualinstances/model_sshpublickey.go | 8 + .../sapvirtualinstances/model_startrequest.go | 8 + .../sapvirtualinstances/model_stoprequest.go | 9 + .../model_storageconfiguration.go | 33 + .../model_threetierconfiguration.go | 100 +++ .../model_threetiercustomresourcenames.go | 75 ++ .../model_threetierfullresourcenames.go | 53 ++ .../model_threetierrecommendationresult.go | 55 ++ ...odel_updatesapvirtualinstanceproperties.go | 8 + .../model_updatesapvirtualinstancerequest.go | 14 + .../model_virtualmachineconfiguration.go | 10 + .../model_virtualmachineresourcenames.go | 12 + .../model_windowsconfiguration.go | 49 ++ .../sapvirtualinstances/predicates.go | 32 + .../2024-09-01/sapvirtualinstances/version.go | 10 + 725 files changed, 51782 insertions(+), 53 deletions(-) create mode 100644 resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go create mode 100644 resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go create mode 100644 resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go create mode 100644 resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/assets/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go create mode 100644 resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go create mode 100644 resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_list.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/method_update.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/predicates.go create mode 100644 resource-manager/operationalinsights/2023-09-01/clusters/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go create mode 100644 resource-manager/operationalinsights/2023-09-01/dataexport/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/predicates.go create mode 100644 resource-manager/operationalinsights/2023-09-01/datasources/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedservices/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go create mode 100644 resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go create mode 100644 resource-manager/operationalinsights/2023-09-01/querypacks/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go create mode 100644 resource-manager/operationalinsights/2023-09-01/savedsearches/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go create mode 100644 resource-manager/operationalinsights/2023-09-01/storageinsights/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/README.md create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/client.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/constants.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/id_table.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_delete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_get.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/method_update.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_column.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_schema.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_table.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/tables/version.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go create mode 100644 resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/README.md create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/client.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/constants.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/method_get.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go create mode 100644 resource-manager/search/2024-06-01-preview/adminkeys/version.go create mode 100644 resource-manager/search/2024-06-01-preview/client.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/README.md create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/client.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go create mode 100644 resource-manager/search/2024-06-01-preview/privatelinkresources/version.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/README.md create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/client.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/method_create.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/method_delete.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/querykeys/version.go create mode 100644 resource-manager/search/2024-06-01-preview/services/README.md create mode 100644 resource-manager/search/2024-06-01-preview/services/client.go create mode 100644 resource-manager/search/2024-06-01-preview/services/constants.go create mode 100644 resource-manager/search/2024-06-01-preview/services/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_createorupdate.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_delete.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_get.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go create mode 100644 resource-manager/search/2024-06-01-preview/services/method_update.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_iprule.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_networkruleset.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/services/model_sku.go create mode 100644 resource-manager/search/2024-06-01-preview/services/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/services/version.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/README.md create mode 100644 resource-manager/search/2024-06-01-preview/usages/client.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/id_location.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/id_location_test.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/id_usage.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/id_usage_test.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/predicates.go create mode 100644 resource-manager/search/2024-06-01-preview/usages/version.go create mode 100644 resource-manager/workloads/2024-09-01/client.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go create mode 100644 resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go create mode 100644 resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go create mode 100644 resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go create mode 100644 resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go new file mode 100644 index 00000000000..87749139a2a --- /dev/null +++ b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go @@ -0,0 +1,10 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseMarketplaceDetailsUpdate struct { + OfferDetails *LiftrBaseOfferDetailsUpdate `json:"offerDetails,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionStatus *MarketplaceSubscriptionStatus `json:"subscriptionStatus,omitempty"` +} diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go new file mode 100644 index 00000000000..4b2d9aed2b4 --- /dev/null +++ b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go @@ -0,0 +1,13 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseOfferDetailsUpdate struct { + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PlanName *string `json:"planName,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + TermId *string `json:"termId,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` +} diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go b/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go index 6d313e73494..e9a3795a650 100644 --- a/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go +++ b/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go @@ -4,6 +4,7 @@ package organizations // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type OrganizationResourceUpdateProperties struct { + Marketplace *LiftrBaseMarketplaceDetailsUpdate `json:"marketplace,omitempty"` PartnerOrganizationProperties *LiftrBaseDataPartnerOrganizationPropertiesUpdate `json:"partnerOrganizationProperties,omitempty"` User *LiftrBaseUserDetailsUpdate `json:"user,omitempty"` } diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go new file mode 100644 index 00000000000..87749139a2a --- /dev/null +++ b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go @@ -0,0 +1,10 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseMarketplaceDetailsUpdate struct { + OfferDetails *LiftrBaseOfferDetailsUpdate `json:"offerDetails,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionStatus *MarketplaceSubscriptionStatus `json:"subscriptionStatus,omitempty"` +} diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go new file mode 100644 index 00000000000..07234d33576 --- /dev/null +++ b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go @@ -0,0 +1,14 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseOfferDetailsUpdate struct { + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PlanName *string `json:"planName,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + RenewalMode *RenewalMode `json:"renewalMode,omitempty"` + TermId *string `json:"termId,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` +} diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go b/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go index 6d313e73494..e9a3795a650 100644 --- a/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go +++ b/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go @@ -4,6 +4,7 @@ package organizations // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type OrganizationResourceUpdateProperties struct { + Marketplace *LiftrBaseMarketplaceDetailsUpdate `json:"marketplace,omitempty"` PartnerOrganizationProperties *LiftrBaseDataPartnerOrganizationPropertiesUpdate `json:"partnerOrganizationProperties,omitempty"` User *LiftrBaseUserDetailsUpdate `json:"user,omitempty"` } diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go index b0a6f866bbf..8e782d61b0d 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go @@ -4,6 +4,7 @@ package dataflowdebugsession // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PostgreSqlV2LinkedServiceTypeProperties struct { + AuthenticationType string `json:"authenticationType"` CommandTimeout *int64 `json:"commandTimeout,omitempty"` ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` Database string `json:"database"` diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go index 2f7976d6f56..f4cd2249456 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go @@ -15,6 +15,7 @@ type SnowflakeLinkedV2ServiceTypeProperties struct { ClientSecret SecretBase `json:"clientSecret"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Password SecretBase `json:"password"` PrivateKey SecretBase `json:"privateKey"` PrivateKeyPassphrase SecretBase `json:"privateKeyPassphrase"` @@ -33,6 +34,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err ClientId *string `json:"clientId,omitempty"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Scope *string `json:"scope,omitempty"` TenantId *string `json:"tenantId,omitempty"` User *string `json:"user,omitempty"` @@ -47,6 +49,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err s.ClientId = decoded.ClientId s.Database = decoded.Database s.EncryptedCredential = decoded.EncryptedCredential + s.Host = decoded.Host s.Scope = decoded.Scope s.TenantId = decoded.TenantId s.User = decoded.User diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go index d78ad7eff5d..5d7c9ab96bf 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go @@ -4,6 +4,7 @@ package linkedservices // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PostgreSqlV2LinkedServiceTypeProperties struct { + AuthenticationType string `json:"authenticationType"` CommandTimeout *int64 `json:"commandTimeout,omitempty"` ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` Database string `json:"database"` diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go index 3933e98ec9a..e0f50bd2152 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go @@ -15,6 +15,7 @@ type SnowflakeLinkedV2ServiceTypeProperties struct { ClientSecret SecretBase `json:"clientSecret"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Password SecretBase `json:"password"` PrivateKey SecretBase `json:"privateKey"` PrivateKeyPassphrase SecretBase `json:"privateKeyPassphrase"` @@ -33,6 +34,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err ClientId *string `json:"clientId,omitempty"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Scope *string `json:"scope,omitempty"` TenantId *string `json:"tenantId,omitempty"` User *string `json:"user,omitempty"` @@ -47,6 +49,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err s.ClientId = decoded.ClientId s.Database = decoded.Database s.EncryptedCredential = decoded.EncryptedCredential + s.Host = decoded.Host s.Scope = decoded.Scope s.TenantId = decoded.TenantId s.User = decoded.User diff --git a/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go b/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go index a51c87a91ab..696635d8308 100644 --- a/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go +++ b/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go @@ -13,6 +13,7 @@ var _ CopySource = SalesforceV2Source{} type SalesforceV2Source struct { AdditionalColumns *interface{} `json:"additionalColumns,omitempty"` IncludeDeletedObjects *bool `json:"includeDeletedObjects,omitempty"` + PageSize *int64 `json:"pageSize,omitempty"` Query *string `json:"query,omitempty"` QueryTimeout *string `json:"queryTimeout,omitempty"` SOQLQuery *string `json:"SOQLQuery,omitempty"` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md new file mode 100644 index 00000000000..798cd7a9f29 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles` Documentation + +The `assetendpointprofiles` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/assetendpointprofiles" +``` + + +### Client Initialization + +```go +client := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetEndpointProfilesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfile{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Delete` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Get` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +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: `AssetEndpointProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Update` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfileUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go new file mode 100644 index 00000000000..099374a758a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go @@ -0,0 +1,26 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient struct { + Client *resourcemanager.Client +} + +func NewAssetEndpointProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetEndpointProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assetendpointprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetEndpointProfilesClient: %+v", err) + } + + return &AssetEndpointProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go new file mode 100644 index 00000000000..3d109615ec0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go @@ -0,0 +1,104 @@ +package assetendpointprofiles + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous" + AuthenticationMethodCertificate AuthenticationMethod = "Certificate" + AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAnonymous), + string(AuthenticationMethodCertificate), + string(AuthenticationMethodUsernamePassword), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "anonymous": AuthenticationMethodAnonymous, + "certificate": AuthenticationMethodCertificate, + "usernamepassword": AuthenticationMethodUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go new file mode 100644 index 00000000000..e372455f8ff --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go @@ -0,0 +1,130 @@ +package assetendpointprofiles + +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(&AssetEndpointProfileId{}) +} + +var _ resourceids.ResourceId = &AssetEndpointProfileId{} + +// AssetEndpointProfileId is a struct representing the Resource ID for a Asset Endpoint Profile +type AssetEndpointProfileId struct { + SubscriptionId string + ResourceGroupName string + AssetEndpointProfileName string +} + +// NewAssetEndpointProfileID returns a new AssetEndpointProfileId struct +func NewAssetEndpointProfileID(subscriptionId string, resourceGroupName string, assetEndpointProfileName string) AssetEndpointProfileId { + return AssetEndpointProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetEndpointProfileName: assetEndpointProfileName, + } +} + +// ParseAssetEndpointProfileID parses 'input' into a AssetEndpointProfileId +func ParseAssetEndpointProfileID(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetEndpointProfileIDInsensitively parses 'input' case-insensitively into a AssetEndpointProfileId +// note: this method should only be used for API response data and not user input +func ParseAssetEndpointProfileIDInsensitively(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetEndpointProfileId) 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.AssetEndpointProfileName, ok = input.Parsed["assetEndpointProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetEndpointProfileName", input) + } + + return nil +} + +// ValidateAssetEndpointProfileID checks that 'input' can be parsed as a Asset Endpoint Profile ID +func ValidateAssetEndpointProfileID(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 := ParseAssetEndpointProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset Endpoint Profile ID +func (id AssetEndpointProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetEndpointProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssetEndpointProfiles", "assetEndpointProfiles", "assetEndpointProfiles"), + resourceids.UserSpecifiedSegment("assetEndpointProfileName", "assetEndpointProfileName"), + } +} + +// String returns a human-readable description of this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Endpoint Profile Name: %q", id.AssetEndpointProfileName), + } + return fmt.Sprintf("Asset Endpoint Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go new file mode 100644 index 00000000000..59928f613b1 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go @@ -0,0 +1,282 @@ +package assetendpointprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AssetEndpointProfileId{} + +func TestNewAssetEndpointProfileID(t *testing.T) { + id := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AssetEndpointProfileName != "assetEndpointProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetEndpointProfileName'", id.AssetEndpointProfileName, "assetEndpointProfileName") + } +} + +func TestFormatAssetEndpointProfileID(t *testing.T) { + actual := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetEndpointProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestParseAssetEndpointProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetEndpointProfileName: "aSsEtEnDpOiNtPrOfIlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestSegmentsForAssetEndpointProfileId(t *testing.T) { + segments := AssetEndpointProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetEndpointProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go new file mode 100644 index 00000000000..1dd13be906d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AssetEndpointProfile +} + +// CreateOrReplace ... +func (c AssetEndpointProfilesClient) CreateOrReplace(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetEndpointProfilesClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go new file mode 100644 index 00000000000..b24134a6027 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go @@ -0,0 +1,70 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient) Delete(ctx context.Context, id AssetEndpointProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 AssetEndpointProfilesClient) DeleteThenPoll(ctx context.Context, id AssetEndpointProfileId) 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/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go new file mode 100644 index 00000000000..2a5f882cc3c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go @@ -0,0 +1,53 @@ +package assetendpointprofiles + +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 *AssetEndpointProfile +} + +// Get ... +func (c AssetEndpointProfilesClient) Get(ctx context.Context, id AssetEndpointProfileId) (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 AssetEndpointProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..dba6b469adb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 *[]AssetEndpointProfile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +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 AssetEndpointProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `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 AssetEndpointProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetEndpointProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go new file mode 100644 index 00000000000..13b32409dc6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AssetEndpointProfile +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetEndpointProfilesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetEndpointProfilesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetEndpointProfileOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go new file mode 100644 index 00000000000..2af77249a09 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AssetEndpointProfile +} + +// Update ... +func (c AssetEndpointProfilesClient) Update(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) (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 AssetEndpointProfilesClient) UpdateThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) 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/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go new file mode 100644 index 00000000000..8968e9fd724 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go @@ -0,0 +1,19 @@ +package assetendpointprofiles + +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 AssetEndpointProfile struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetEndpointProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go new file mode 100644 index 00000000000..f4ca0e2ffc3 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go @@ -0,0 +1,15 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *Authentication `json:"authentication,omitempty"` + DiscoveredAssetEndpointProfileRef *string `json:"discoveredAssetEndpointProfileRef,omitempty"` + EndpointProfileType string `json:"endpointProfileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *AssetEndpointProfileStatus `json:"status,omitempty"` + TargetAddress string `json:"targetAddress"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go new file mode 100644 index 00000000000..b9352a519b4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatus struct { + Errors *[]AssetEndpointProfileStatusError `json:"errors,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go new file mode 100644 index 00000000000..43ef3ee7188 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go new file mode 100644 index 00000000000..0bfe7125133 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdate struct { + Properties *AssetEndpointProfileUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go new file mode 100644 index 00000000000..a05bb6eefb0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go @@ -0,0 +1,11 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdateProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *AuthenticationUpdate `json:"authentication,omitempty"` + EndpointProfileType *string `json:"endpointProfileType,omitempty"` + TargetAddress *string `json:"targetAddress,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go new file mode 100644 index 00000000000..67a43dfa2cd --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Authentication struct { + Method AuthenticationMethod `json:"method"` + UsernamePasswordCredentials *UsernamePasswordCredentials `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509Credentials `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go new file mode 100644 index 00000000000..b0f0d7ef0f6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationUpdate struct { + Method *AuthenticationMethod `json:"method,omitempty"` + UsernamePasswordCredentials *UsernamePasswordCredentialsUpdate `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509CredentialsUpdate `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go new file mode 100644 index 00000000000..0fb2e13abac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go new file mode 100644 index 00000000000..b108ab27db6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentials struct { + PasswordSecretName string `json:"passwordSecretName"` + UsernameSecretName string `json:"usernameSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go new file mode 100644 index 00000000000..cf842482565 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentialsUpdate struct { + PasswordSecretName *string `json:"passwordSecretName,omitempty"` + UsernameSecretName *string `json:"usernameSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go new file mode 100644 index 00000000000..5b3cd78827c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509Credentials struct { + CertificateSecretName string `json:"certificateSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go new file mode 100644 index 00000000000..920bb4fb03b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509CredentialsUpdate struct { + CertificateSecretName *string `json:"certificateSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go new file mode 100644 index 00000000000..fb0fb8f73eb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go @@ -0,0 +1,32 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetEndpointProfileOperationPredicate) Matches(input AssetEndpointProfile) 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/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go new file mode 100644 index 00000000000..2e71fa681b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assetendpointprofiles/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md b/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md new file mode 100644 index 00000000000..1a6d4c6a145 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assets` Documentation + +The `assets` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/assets" +``` + + +### Client Initialization + +```go +client := assets.NewAssetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.Asset{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Delete` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Get` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +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: `AssetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.Update` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.AssetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go new file mode 100644 index 00000000000..a72f6492047 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go @@ -0,0 +1,26 @@ +package assets + +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 AssetsClient struct { + Client *resourcemanager.Client +} + +func NewAssetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetsClient: %+v", err) + } + + return &AssetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go new file mode 100644 index 00000000000..ac288b94567 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go @@ -0,0 +1,192 @@ +package assets + +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 DataPointObservabilityMode string + +const ( + DataPointObservabilityModeCounter DataPointObservabilityMode = "Counter" + DataPointObservabilityModeGauge DataPointObservabilityMode = "Gauge" + DataPointObservabilityModeHistogram DataPointObservabilityMode = "Histogram" + DataPointObservabilityModeLog DataPointObservabilityMode = "Log" + DataPointObservabilityModeNone DataPointObservabilityMode = "None" +) + +func PossibleValuesForDataPointObservabilityMode() []string { + return []string{ + string(DataPointObservabilityModeCounter), + string(DataPointObservabilityModeGauge), + string(DataPointObservabilityModeHistogram), + string(DataPointObservabilityModeLog), + string(DataPointObservabilityModeNone), + } +} + +func (s *DataPointObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataPointObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataPointObservabilityMode(input string) (*DataPointObservabilityMode, error) { + vals := map[string]DataPointObservabilityMode{ + "counter": DataPointObservabilityModeCounter, + "gauge": DataPointObservabilityModeGauge, + "histogram": DataPointObservabilityModeHistogram, + "log": DataPointObservabilityModeLog, + "none": DataPointObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataPointObservabilityMode(input) + return &out, nil +} + +type EventObservabilityMode string + +const ( + EventObservabilityModeLog EventObservabilityMode = "Log" + EventObservabilityModeNone EventObservabilityMode = "None" +) + +func PossibleValuesForEventObservabilityMode() []string { + return []string{ + string(EventObservabilityModeLog), + string(EventObservabilityModeNone), + } +} + +func (s *EventObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventObservabilityMode(input string) (*EventObservabilityMode, error) { + vals := map[string]EventObservabilityMode{ + "log": EventObservabilityModeLog, + "none": EventObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventObservabilityMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 TopicRetainType string + +const ( + TopicRetainTypeKeep TopicRetainType = "Keep" + TopicRetainTypeNever TopicRetainType = "Never" +) + +func PossibleValuesForTopicRetainType() []string { + return []string{ + string(TopicRetainTypeKeep), + string(TopicRetainTypeNever), + } +} + +func (s *TopicRetainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTopicRetainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTopicRetainType(input string) (*TopicRetainType, error) { + vals := map[string]TopicRetainType{ + "keep": TopicRetainTypeKeep, + "never": TopicRetainTypeNever, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TopicRetainType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go new file mode 100644 index 00000000000..bb7b45f0c33 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go @@ -0,0 +1,130 @@ +package assets + +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(&AssetId{}) +} + +var _ resourceids.ResourceId = &AssetId{} + +// AssetId is a struct representing the Resource ID for a Asset +type AssetId struct { + SubscriptionId string + ResourceGroupName string + AssetName string +} + +// NewAssetID returns a new AssetId struct +func NewAssetID(subscriptionId string, resourceGroupName string, assetName string) AssetId { + return AssetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetName: assetName, + } +} + +// ParseAssetID parses 'input' into a AssetId +func ParseAssetID(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetIDInsensitively parses 'input' case-insensitively into a AssetId +// note: this method should only be used for API response data and not user input +func ParseAssetIDInsensitively(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetId) 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.AssetName, ok = input.Parsed["assetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetName", input) + } + + return nil +} + +// ValidateAssetID checks that 'input' can be parsed as a Asset ID +func ValidateAssetID(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 := ParseAssetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset ID +func (id AssetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset ID +func (id AssetId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssets", "assets", "assets"), + resourceids.UserSpecifiedSegment("assetName", "assetName"), + } +} + +// String returns a human-readable description of this Asset ID +func (id AssetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Name: %q", id.AssetName), + } + return fmt.Sprintf("Asset (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go new file mode 100644 index 00000000000..533809babad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go @@ -0,0 +1,282 @@ +package assets + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AssetId{} + +func TestNewAssetID(t *testing.T) { + id := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AssetName != "assetName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetName'", id.AssetName, "assetName") + } +} + +func TestFormatAssetID(t *testing.T) { + actual := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestParseAssetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetName: "aSsEtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestSegmentsForAssetId(t *testing.T) { + segments := AssetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go new file mode 100644 index 00000000000..b6a7798f315 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go @@ -0,0 +1,75 @@ +package assets + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Asset +} + +// CreateOrReplace ... +func (c AssetsClient) CreateOrReplace(ctx context.Context, id AssetId, input Asset) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetsClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetId, input Asset) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go new file mode 100644 index 00000000000..34b6146a5f2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go @@ -0,0 +1,70 @@ +package assets + +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 AssetsClient) Delete(ctx context.Context, id AssetId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 AssetsClient) DeleteThenPoll(ctx context.Context, id AssetId) 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/resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go new file mode 100644 index 00000000000..8eabe4d065a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go @@ -0,0 +1,53 @@ +package assets + +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 *Asset +} + +// Get ... +func (c AssetsClient) Get(ctx context.Context, id AssetId) (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 Asset + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..c063d4d77db --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assets + +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 *[]Asset +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +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 AssetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `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 AssetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go new file mode 100644 index 00000000000..fe6c812e1cb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Asset +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go new file mode 100644 index 00000000000..42754ffb942 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go @@ -0,0 +1,75 @@ +package assets + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Asset +} + +// Update ... +func (c AssetsClient) Update(ctx context.Context, id AssetId, input AssetUpdate) (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 AssetsClient) UpdateThenPoll(ctx context.Context, id AssetId, input AssetUpdate) 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/resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go new file mode 100644 index 00000000000..24857b429fa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go @@ -0,0 +1,19 @@ +package assets + +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 Asset struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go new file mode 100644 index 00000000000..73ce93da09b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go @@ -0,0 +1,31 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetProperties struct { + AssetEndpointProfileRef string `json:"assetEndpointProfileRef"` + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *Topic `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DiscoveredAssetRefs *[]string `json:"discoveredAssetRefs,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + ExternalAssetId *string `json:"externalAssetId,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Status *AssetStatus `json:"status,omitempty"` + Uuid *string `json:"uuid,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go new file mode 100644 index 00000000000..59adc5ba1c8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatus struct { + Datasets *[]AssetStatusDataset `json:"datasets,omitempty"` + Errors *[]AssetStatusError `json:"errors,omitempty"` + Events *[]AssetStatusEvent `json:"events,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go new file mode 100644 index 00000000000..511593b5e8f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusDataset struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go new file mode 100644 index 00000000000..c87108ecc08 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go new file mode 100644 index 00000000000..2438f4620ca --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusEvent struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go new file mode 100644 index 00000000000..6ff6aa0a80b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdate struct { + Properties *AssetUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go new file mode 100644 index 00000000000..e18024904a9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go @@ -0,0 +1,24 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdateProperties struct { + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *TopicUpdate `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go new file mode 100644 index 00000000000..45563621600 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPoint struct { + DataPointConfiguration *string `json:"dataPointConfiguration,omitempty"` + DataSource string `json:"dataSource"` + Name string `json:"name"` + ObservabilityMode *DataPointObservabilityMode `json:"observabilityMode,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go new file mode 100644 index 00000000000..6bd5a412380 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dataset struct { + DataPoints *[]DataPoint `json:"dataPoints,omitempty"` + DatasetConfiguration *string `json:"datasetConfiguration,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go new file mode 100644 index 00000000000..0586fe3f37b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go @@ -0,0 +1,12 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Event struct { + EventConfiguration *string `json:"eventConfiguration,omitempty"` + EventNotifier string `json:"eventNotifier"` + Name string `json:"name"` + ObservabilityMode *EventObservabilityMode `json:"observabilityMode,omitempty"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go new file mode 100644 index 00000000000..1ab2aa85f80 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go new file mode 100644 index 00000000000..098722031b9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageSchemaReference struct { + SchemaName string `json:"schemaName"` + SchemaRegistryNamespace string `json:"schemaRegistryNamespace"` + SchemaVersion string `json:"schemaVersion"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go new file mode 100644 index 00000000000..83d513322ab --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topic struct { + Path string `json:"path"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go new file mode 100644 index 00000000000..d43a63c0c8e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicUpdate struct { + Path *string `json:"path,omitempty"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go new file mode 100644 index 00000000000..cedd4ebc101 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go @@ -0,0 +1,32 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetOperationPredicate) Matches(input Asset) 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/resource-manager/deviceregistry/2024-09-01-preview/assets/version.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/version.go new file mode 100644 index 00000000000..fcc427b2641 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/version.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assets/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md new file mode 100644 index 00000000000..0bb950ad436 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers` Documentation + +The `billingcontainers` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/billingcontainers" +``` + + +### Client Initialization + +```go +client := billingcontainers.NewBillingContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BillingContainersClient.Get` + +```go +ctx := context.TODO() +id := billingcontainers.NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + +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: `BillingContainersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go new file mode 100644 index 00000000000..3361e18593c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go @@ -0,0 +1,26 @@ +package billingcontainers + +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 BillingContainersClient struct { + Client *resourcemanager.Client +} + +func NewBillingContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*BillingContainersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "billingcontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BillingContainersClient: %+v", err) + } + + return &BillingContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go new file mode 100644 index 00000000000..b98bfe20660 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go @@ -0,0 +1,60 @@ +package billingcontainers + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go new file mode 100644 index 00000000000..38f08f9926f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go @@ -0,0 +1,121 @@ +package billingcontainers + +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(&BillingContainerId{}) +} + +var _ resourceids.ResourceId = &BillingContainerId{} + +// BillingContainerId is a struct representing the Resource ID for a Billing Container +type BillingContainerId struct { + SubscriptionId string + BillingContainerName string +} + +// NewBillingContainerID returns a new BillingContainerId struct +func NewBillingContainerID(subscriptionId string, billingContainerName string) BillingContainerId { + return BillingContainerId{ + SubscriptionId: subscriptionId, + BillingContainerName: billingContainerName, + } +} + +// ParseBillingContainerID parses 'input' into a BillingContainerId +func ParseBillingContainerID(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBillingContainerIDInsensitively parses 'input' case-insensitively into a BillingContainerId +// note: this method should only be used for API response data and not user input +func ParseBillingContainerIDInsensitively(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BillingContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.BillingContainerName, ok = input.Parsed["billingContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "billingContainerName", input) + } + + return nil +} + +// ValidateBillingContainerID checks that 'input' can be parsed as a Billing Container ID +func ValidateBillingContainerID(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 := ParseBillingContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Billing Container ID +func (id BillingContainerId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DeviceRegistry/billingContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.BillingContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Billing Container ID +func (id BillingContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticBillingContainers", "billingContainers", "billingContainers"), + resourceids.UserSpecifiedSegment("billingContainerName", "billingContainerName"), + } +} + +// String returns a human-readable description of this Billing Container ID +func (id BillingContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Billing Container Name: %q", id.BillingContainerName), + } + return fmt.Sprintf("Billing Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go new file mode 100644 index 00000000000..3f44a3afbf9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go @@ -0,0 +1,237 @@ +package billingcontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BillingContainerId{} + +func TestNewBillingContainerID(t *testing.T) { + id := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.BillingContainerName != "billingContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'BillingContainerName'", id.BillingContainerName, "billingContainerName") + } +} + +func TestFormatBillingContainerID(t *testing.T) { + actual := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBillingContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestParseBillingContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "bIlLiNgCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestSegmentsForBillingContainerId(t *testing.T) { + segments := BillingContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BillingContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go new file mode 100644 index 00000000000..564089fc3d8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go @@ -0,0 +1,53 @@ +package billingcontainers + +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 *BillingContainer +} + +// Get ... +func (c BillingContainersClient) Get(ctx context.Context, id BillingContainerId) (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 BillingContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go new file mode 100644 index 00000000000..4f6fa1d21b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go @@ -0,0 +1,106 @@ +package billingcontainers + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingContainer +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingContainer +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c BillingContainersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/billingContainers", 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 *[]BillingContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c BillingContainersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, BillingContainerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BillingContainersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BillingContainerOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]BillingContainer, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go new file mode 100644 index 00000000000..d897ec1b71d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go @@ -0,0 +1,17 @@ +package billingcontainers + +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 BillingContainer struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingContainerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go new file mode 100644 index 00000000000..ad3f625d084 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go @@ -0,0 +1,8 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go new file mode 100644 index 00000000000..8e61fac37ac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go @@ -0,0 +1,32 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p BillingContainerOperationPredicate) Matches(input BillingContainer) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go new file mode 100644 index 00000000000..2cee2f9ebbc --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go @@ -0,0 +1,10 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/billingcontainers/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/client.go b/resource-manager/deviceregistry/2024-09-01-preview/client.go new file mode 100644 index 00000000000..549e5299243 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/client.go @@ -0,0 +1,91 @@ +package v2024_09_01_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assets" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemas" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AssetEndpointProfiles *assetendpointprofiles.AssetEndpointProfilesClient + Assets *assets.AssetsClient + BillingContainers *billingcontainers.BillingContainersClient + DiscoveredAssetEndpointProfiles *discoveredassetendpointprofiles.DiscoveredAssetEndpointProfilesClient + DiscoveredAssets *discoveredassets.DiscoveredAssetsClient + SchemaRegistries *schemaregistries.SchemaRegistriesClient + SchemaVersions *schemaversions.SchemaVersionsClient + Schemas *schemas.SchemasClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + assetEndpointProfilesClient, err := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AssetEndpointProfiles client: %+v", err) + } + configureFunc(assetEndpointProfilesClient.Client) + + assetsClient, err := assets.NewAssetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Assets client: %+v", err) + } + configureFunc(assetsClient.Client) + + billingContainersClient, err := billingcontainers.NewBillingContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BillingContainers client: %+v", err) + } + configureFunc(billingContainersClient.Client) + + discoveredAssetEndpointProfilesClient, err := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DiscoveredAssetEndpointProfiles client: %+v", err) + } + configureFunc(discoveredAssetEndpointProfilesClient.Client) + + discoveredAssetsClient, err := discoveredassets.NewDiscoveredAssetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DiscoveredAssets client: %+v", err) + } + configureFunc(discoveredAssetsClient.Client) + + schemaRegistriesClient, err := schemaregistries.NewSchemaRegistriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SchemaRegistries client: %+v", err) + } + configureFunc(schemaRegistriesClient.Client) + + schemaVersionsClient, err := schemaversions.NewSchemaVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SchemaVersions client: %+v", err) + } + configureFunc(schemaVersionsClient.Client) + + schemasClient, err := schemas.NewSchemasClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Schemas client: %+v", err) + } + configureFunc(schemasClient.Client) + + return &Client{ + AssetEndpointProfiles: assetEndpointProfilesClient, + Assets: assetsClient, + BillingContainers: billingContainersClient, + DiscoveredAssetEndpointProfiles: discoveredAssetEndpointProfilesClient, + DiscoveredAssets: discoveredAssetsClient, + SchemaRegistries: schemaRegistriesClient, + SchemaVersions: schemaVersionsClient, + Schemas: schemasClient, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md new file mode 100644 index 00000000000..99ad1ff8944 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles` Documentation + +The `discoveredassetendpointprofiles` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles" +``` + + +### Client Initialization + +```go +client := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +payload := discoveredassetendpointprofiles.DiscoveredAssetEndpointProfile{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Delete` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Get` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +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: `DiscoveredAssetEndpointProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Update` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +payload := discoveredassetendpointprofiles.DiscoveredAssetEndpointProfileUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go new file mode 100644 index 00000000000..9f4c2c24574 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go @@ -0,0 +1,26 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfilesClient struct { + Client *resourcemanager.Client +} + +func NewDiscoveredAssetEndpointProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*DiscoveredAssetEndpointProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "discoveredassetendpointprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiscoveredAssetEndpointProfilesClient: %+v", err) + } + + return &DiscoveredAssetEndpointProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go new file mode 100644 index 00000000000..a024f11de50 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go @@ -0,0 +1,104 @@ +package discoveredassetendpointprofiles + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous" + AuthenticationMethodCertificate AuthenticationMethod = "Certificate" + AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAnonymous), + string(AuthenticationMethodCertificate), + string(AuthenticationMethodUsernamePassword), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "anonymous": AuthenticationMethodAnonymous, + "certificate": AuthenticationMethodCertificate, + "usernamepassword": AuthenticationMethodUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go new file mode 100644 index 00000000000..9efa4cfcdba --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go @@ -0,0 +1,130 @@ +package discoveredassetendpointprofiles + +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(&DiscoveredAssetEndpointProfileId{}) +} + +var _ resourceids.ResourceId = &DiscoveredAssetEndpointProfileId{} + +// DiscoveredAssetEndpointProfileId is a struct representing the Resource ID for a Discovered Asset Endpoint Profile +type DiscoveredAssetEndpointProfileId struct { + SubscriptionId string + ResourceGroupName string + DiscoveredAssetEndpointProfileName string +} + +// NewDiscoveredAssetEndpointProfileID returns a new DiscoveredAssetEndpointProfileId struct +func NewDiscoveredAssetEndpointProfileID(subscriptionId string, resourceGroupName string, discoveredAssetEndpointProfileName string) DiscoveredAssetEndpointProfileId { + return DiscoveredAssetEndpointProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DiscoveredAssetEndpointProfileName: discoveredAssetEndpointProfileName, + } +} + +// ParseDiscoveredAssetEndpointProfileID parses 'input' into a DiscoveredAssetEndpointProfileId +func ParseDiscoveredAssetEndpointProfileID(input string) (*DiscoveredAssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetEndpointProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiscoveredAssetEndpointProfileIDInsensitively parses 'input' case-insensitively into a DiscoveredAssetEndpointProfileId +// note: this method should only be used for API response data and not user input +func ParseDiscoveredAssetEndpointProfileIDInsensitively(input string) (*DiscoveredAssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetEndpointProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiscoveredAssetEndpointProfileId) 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.DiscoveredAssetEndpointProfileName, ok = input.Parsed["discoveredAssetEndpointProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "discoveredAssetEndpointProfileName", input) + } + + return nil +} + +// ValidateDiscoveredAssetEndpointProfileID checks that 'input' can be parsed as a Discovered Asset Endpoint Profile ID +func ValidateDiscoveredAssetEndpointProfileID(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 := ParseDiscoveredAssetEndpointProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DiscoveredAssetEndpointProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticDiscoveredAssetEndpointProfiles", "discoveredAssetEndpointProfiles", "discoveredAssetEndpointProfiles"), + resourceids.UserSpecifiedSegment("discoveredAssetEndpointProfileName", "discoveredAssetEndpointProfileName"), + } +} + +// String returns a human-readable description of this Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Discovered Asset Endpoint Profile Name: %q", id.DiscoveredAssetEndpointProfileName), + } + return fmt.Sprintf("Discovered Asset Endpoint Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go new file mode 100644 index 00000000000..8d95d40c742 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go @@ -0,0 +1,282 @@ +package discoveredassetendpointprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiscoveredAssetEndpointProfileId{} + +func TestNewDiscoveredAssetEndpointProfileID(t *testing.T) { + id := NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DiscoveredAssetEndpointProfileName != "discoveredAssetEndpointProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'DiscoveredAssetEndpointProfileName'", id.DiscoveredAssetEndpointProfileName, "discoveredAssetEndpointProfileName") + } +} + +func TestFormatDiscoveredAssetEndpointProfileID(t *testing.T) { + actual := NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiscoveredAssetEndpointProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetEndpointProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetEndpointProfileName: "discoveredAssetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetEndpointProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DiscoveredAssetEndpointProfileName != v.Expected.DiscoveredAssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetEndpointProfileName", v.Expected.DiscoveredAssetEndpointProfileName, actual.DiscoveredAssetEndpointProfileName) + } + + } +} + +func TestParseDiscoveredAssetEndpointProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetEndpointProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetEndpointProfileName: "discoveredAssetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DiscoveredAssetEndpointProfileName: "dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetEndpointProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DiscoveredAssetEndpointProfileName != v.Expected.DiscoveredAssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetEndpointProfileName", v.Expected.DiscoveredAssetEndpointProfileName, actual.DiscoveredAssetEndpointProfileName) + } + + } +} + +func TestSegmentsForDiscoveredAssetEndpointProfileId(t *testing.T) { + segments := DiscoveredAssetEndpointProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiscoveredAssetEndpointProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go new file mode 100644 index 00000000000..5aa061769a4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go @@ -0,0 +1,75 @@ +package discoveredassetendpointprofiles + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAssetEndpointProfile +} + +// CreateOrReplace ... +func (c DiscoveredAssetEndpointProfilesClient) CreateOrReplace(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfile) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c DiscoveredAssetEndpointProfilesClient) CreateOrReplaceThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfile) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go new file mode 100644 index 00000000000..e4d5a59d350 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go @@ -0,0 +1,70 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfilesClient) Delete(ctx context.Context, id DiscoveredAssetEndpointProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 DiscoveredAssetEndpointProfilesClient) DeleteThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go new file mode 100644 index 00000000000..3a2e3e19817 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go @@ -0,0 +1,53 @@ +package discoveredassetendpointprofiles + +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 *DiscoveredAssetEndpointProfile +} + +// Get ... +func (c DiscoveredAssetEndpointProfilesClient) Get(ctx context.Context, id DiscoveredAssetEndpointProfileId) (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 DiscoveredAssetEndpointProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ef9d06d005a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package discoveredassetendpointprofiles + +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 *[]DiscoveredAssetEndpointProfile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAssetEndpointProfile +} + +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 DiscoveredAssetEndpointProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", 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 *[]DiscoveredAssetEndpointProfile `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 DiscoveredAssetEndpointProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DiscoveredAssetEndpointProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetEndpointProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DiscoveredAssetEndpointProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DiscoveredAssetEndpointProfile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go new file mode 100644 index 00000000000..d371020d2d0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go @@ -0,0 +1,106 @@ +package discoveredassetendpointprofiles + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAssetEndpointProfile +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAssetEndpointProfile +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", 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 *[]DiscoveredAssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DiscoveredAssetEndpointProfileOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DiscoveredAssetEndpointProfileOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DiscoveredAssetEndpointProfile, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go new file mode 100644 index 00000000000..cf5a777ed45 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go @@ -0,0 +1,75 @@ +package discoveredassetendpointprofiles + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAssetEndpointProfile +} + +// Update ... +func (c DiscoveredAssetEndpointProfilesClient) Update(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfileUpdate) (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 DiscoveredAssetEndpointProfilesClient) UpdateThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfileUpdate) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go new file mode 100644 index 00000000000..1fe91b9b8a0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go @@ -0,0 +1,19 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfile struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DiscoveredAssetEndpointProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go new file mode 100644 index 00000000000..1b5dcc4b19f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go @@ -0,0 +1,14 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + DiscoveryId string `json:"discoveryId"` + EndpointProfileType string `json:"endpointProfileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SupportedAuthenticationMethods *[]AuthenticationMethod `json:"supportedAuthenticationMethods,omitempty"` + TargetAddress string `json:"targetAddress"` + Version int64 `json:"version"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go new file mode 100644 index 00000000000..8ed369c6eab --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go @@ -0,0 +1,9 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileUpdate struct { + Properties *DiscoveredAssetEndpointProfileUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go new file mode 100644 index 00000000000..93a56715a2a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go @@ -0,0 +1,13 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileUpdateProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + DiscoveryId *string `json:"discoveryId,omitempty"` + EndpointProfileType *string `json:"endpointProfileType,omitempty"` + SupportedAuthenticationMethods *[]AuthenticationMethod `json:"supportedAuthenticationMethods,omitempty"` + TargetAddress *string `json:"targetAddress,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go new file mode 100644 index 00000000000..35b60166210 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go @@ -0,0 +1,9 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go new file mode 100644 index 00000000000..db898423dae --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go @@ -0,0 +1,32 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DiscoveredAssetEndpointProfileOperationPredicate) Matches(input DiscoveredAssetEndpointProfile) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go new file mode 100644 index 00000000000..1fc73986e73 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go @@ -0,0 +1,10 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/discoveredassetendpointprofiles/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md new file mode 100644 index 00000000000..e863d64112b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets` Documentation + +The `discoveredassets` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/discoveredassets" +``` + + +### Client Initialization + +```go +client := discoveredassets.NewDiscoveredAssetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiscoveredAssetsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +payload := discoveredassets.DiscoveredAsset{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Delete` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Get` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +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: `DiscoveredAssetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Update` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +payload := discoveredassets.DiscoveredAssetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go new file mode 100644 index 00000000000..452f44d72e8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go @@ -0,0 +1,26 @@ +package discoveredassets + +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 DiscoveredAssetsClient struct { + Client *resourcemanager.Client +} + +func NewDiscoveredAssetsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiscoveredAssetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "discoveredassets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiscoveredAssetsClient: %+v", err) + } + + return &DiscoveredAssetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go new file mode 100644 index 00000000000..29ea51464da --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go @@ -0,0 +1,101 @@ +package discoveredassets + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 TopicRetainType string + +const ( + TopicRetainTypeKeep TopicRetainType = "Keep" + TopicRetainTypeNever TopicRetainType = "Never" +) + +func PossibleValuesForTopicRetainType() []string { + return []string{ + string(TopicRetainTypeKeep), + string(TopicRetainTypeNever), + } +} + +func (s *TopicRetainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTopicRetainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTopicRetainType(input string) (*TopicRetainType, error) { + vals := map[string]TopicRetainType{ + "keep": TopicRetainTypeKeep, + "never": TopicRetainTypeNever, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TopicRetainType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go new file mode 100644 index 00000000000..330575dca73 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go @@ -0,0 +1,130 @@ +package discoveredassets + +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(&DiscoveredAssetId{}) +} + +var _ resourceids.ResourceId = &DiscoveredAssetId{} + +// DiscoveredAssetId is a struct representing the Resource ID for a Discovered Asset +type DiscoveredAssetId struct { + SubscriptionId string + ResourceGroupName string + DiscoveredAssetName string +} + +// NewDiscoveredAssetID returns a new DiscoveredAssetId struct +func NewDiscoveredAssetID(subscriptionId string, resourceGroupName string, discoveredAssetName string) DiscoveredAssetId { + return DiscoveredAssetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DiscoveredAssetName: discoveredAssetName, + } +} + +// ParseDiscoveredAssetID parses 'input' into a DiscoveredAssetId +func ParseDiscoveredAssetID(input string) (*DiscoveredAssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiscoveredAssetIDInsensitively parses 'input' case-insensitively into a DiscoveredAssetId +// note: this method should only be used for API response data and not user input +func ParseDiscoveredAssetIDInsensitively(input string) (*DiscoveredAssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiscoveredAssetId) 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.DiscoveredAssetName, ok = input.Parsed["discoveredAssetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "discoveredAssetName", input) + } + + return nil +} + +// ValidateDiscoveredAssetID checks that 'input' can be parsed as a Discovered Asset ID +func ValidateDiscoveredAssetID(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 := ParseDiscoveredAssetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Discovered Asset ID +func (id DiscoveredAssetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/discoveredAssets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DiscoveredAssetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Discovered Asset ID +func (id DiscoveredAssetId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticDiscoveredAssets", "discoveredAssets", "discoveredAssets"), + resourceids.UserSpecifiedSegment("discoveredAssetName", "discoveredAssetName"), + } +} + +// String returns a human-readable description of this Discovered Asset ID +func (id DiscoveredAssetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Discovered Asset Name: %q", id.DiscoveredAssetName), + } + return fmt.Sprintf("Discovered Asset (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go new file mode 100644 index 00000000000..7c935a1f3b5 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go @@ -0,0 +1,282 @@ +package discoveredassets + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiscoveredAssetId{} + +func TestNewDiscoveredAssetID(t *testing.T) { + id := NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DiscoveredAssetName != "discoveredAssetName" { + t.Fatalf("Expected %q but got %q for Segment 'DiscoveredAssetName'", id.DiscoveredAssetName, "discoveredAssetName") + } +} + +func TestFormatDiscoveredAssetID(t *testing.T) { + actual := NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiscoveredAssetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetName: "discoveredAssetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DiscoveredAssetName != v.Expected.DiscoveredAssetName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetName", v.Expected.DiscoveredAssetName, actual.DiscoveredAssetName) + } + + } +} + +func TestParseDiscoveredAssetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetName: "discoveredAssetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS/dIsCoVeReDaSsEtNaMe", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DiscoveredAssetName: "dIsCoVeReDaSsEtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS/dIsCoVeReDaSsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DiscoveredAssetName != v.Expected.DiscoveredAssetName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetName", v.Expected.DiscoveredAssetName, actual.DiscoveredAssetName) + } + + } +} + +func TestSegmentsForDiscoveredAssetId(t *testing.T) { + segments := DiscoveredAssetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiscoveredAssetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go new file mode 100644 index 00000000000..9d7294be792 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go @@ -0,0 +1,75 @@ +package discoveredassets + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAsset +} + +// CreateOrReplace ... +func (c DiscoveredAssetsClient) CreateOrReplace(ctx context.Context, id DiscoveredAssetId, input DiscoveredAsset) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c DiscoveredAssetsClient) CreateOrReplaceThenPoll(ctx context.Context, id DiscoveredAssetId, input DiscoveredAsset) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go new file mode 100644 index 00000000000..5b61cbae495 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go @@ -0,0 +1,70 @@ +package discoveredassets + +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 DiscoveredAssetsClient) Delete(ctx context.Context, id DiscoveredAssetId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 DiscoveredAssetsClient) DeleteThenPoll(ctx context.Context, id DiscoveredAssetId) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go new file mode 100644 index 00000000000..967affec5ad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go @@ -0,0 +1,53 @@ +package discoveredassets + +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 *DiscoveredAsset +} + +// Get ... +func (c DiscoveredAssetsClient) Get(ctx context.Context, id DiscoveredAssetId) (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 DiscoveredAsset + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..4c50cb450af --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package discoveredassets + +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 *[]DiscoveredAsset +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAsset +} + +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 DiscoveredAssetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssets", 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 *[]DiscoveredAsset `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 DiscoveredAssetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DiscoveredAssetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DiscoveredAssetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DiscoveredAsset, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go new file mode 100644 index 00000000000..467fe3e3b7e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package discoveredassets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAsset +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAsset +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c DiscoveredAssetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssets", 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 *[]DiscoveredAsset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DiscoveredAssetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DiscoveredAssetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DiscoveredAssetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DiscoveredAsset, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go new file mode 100644 index 00000000000..34dafc0b83a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go @@ -0,0 +1,75 @@ +package discoveredassets + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAsset +} + +// Update ... +func (c DiscoveredAssetsClient) Update(ctx context.Context, id DiscoveredAssetId, input DiscoveredAssetUpdate) (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 DiscoveredAssetsClient) UpdateThenPoll(ctx context.Context, id DiscoveredAssetId, input DiscoveredAssetUpdate) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go new file mode 100644 index 00000000000..c2115751f9a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go @@ -0,0 +1,19 @@ +package discoveredassets + +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 DiscoveredAsset struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DiscoveredAssetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go new file mode 100644 index 00000000000..5dd4c43534f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go @@ -0,0 +1,24 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetProperties struct { + AssetEndpointProfileRef string `json:"assetEndpointProfileRef"` + Datasets *[]DiscoveredDataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *Topic `json:"defaultTopic,omitempty"` + DiscoveryId string `json:"discoveryId"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Events *[]DiscoveredEvent `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Version int64 `json:"version"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go new file mode 100644 index 00000000000..cde7515625f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetUpdate struct { + Properties *DiscoveredAssetUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go new file mode 100644 index 00000000000..f1730c339e2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go @@ -0,0 +1,22 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetUpdateProperties struct { + Datasets *[]DiscoveredDataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *TopicUpdate `json:"defaultTopic,omitempty"` + DiscoveryId *string `json:"discoveryId,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Events *[]DiscoveredEvent `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go new file mode 100644 index 00000000000..7f85a50a982 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go @@ -0,0 +1,29 @@ +package discoveredassets + +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 DiscoveredDataPoint struct { + DataPointConfiguration *string `json:"dataPointConfiguration,omitempty"` + DataSource string `json:"dataSource"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + Name string `json:"name"` +} + +func (o *DiscoveredDataPoint) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiscoveredDataPoint) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go new file mode 100644 index 00000000000..3fa178e5f19 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go @@ -0,0 +1,11 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredDataset struct { + DataPoints *[]DiscoveredDataPoint `json:"dataPoints,omitempty"` + DatasetConfiguration *string `json:"datasetConfiguration,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go new file mode 100644 index 00000000000..b2f4650a037 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go @@ -0,0 +1,30 @@ +package discoveredassets + +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 DiscoveredEvent struct { + EventConfiguration *string `json:"eventConfiguration,omitempty"` + EventNotifier string `json:"eventNotifier"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} + +func (o *DiscoveredEvent) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiscoveredEvent) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go new file mode 100644 index 00000000000..819a06a5083 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go new file mode 100644 index 00000000000..66f0a946718 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topic struct { + Path string `json:"path"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go new file mode 100644 index 00000000000..c5fc8fab903 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicUpdate struct { + Path *string `json:"path,omitempty"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go new file mode 100644 index 00000000000..dd1b7e7a45a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go @@ -0,0 +1,32 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DiscoveredAssetOperationPredicate) Matches(input DiscoveredAsset) 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/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go new file mode 100644 index 00000000000..02957409f9e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go @@ -0,0 +1,10 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/discoveredassets/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md new file mode 100644 index 00000000000..8db970cf90e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries` Documentation + +The `schemaregistries` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/schemaregistries" +``` + + +### Client Initialization + +```go +client := schemaregistries.NewSchemaRegistriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemaRegistriesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +payload := schemaregistries.SchemaRegistry{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SchemaRegistriesClient.Delete` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SchemaRegistriesClient.Get` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +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: `SchemaRegistriesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SchemaRegistriesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SchemaRegistriesClient.Update` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +payload := schemaregistries.SchemaRegistryUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go new file mode 100644 index 00000000000..26d52a1bee7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go @@ -0,0 +1,26 @@ +package schemaregistries + +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 SchemaRegistriesClient struct { + Client *resourcemanager.Client +} + +func NewSchemaRegistriesClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemaRegistriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemaregistries", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaRegistriesClient: %+v", err) + } + + return &SchemaRegistriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go new file mode 100644 index 00000000000..784b072f900 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go @@ -0,0 +1,60 @@ +package schemaregistries + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go new file mode 100644 index 00000000000..257760f1220 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go @@ -0,0 +1,130 @@ +package schemaregistries + +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(&SchemaRegistryId{}) +} + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +// SchemaRegistryId is a struct representing the Resource ID for a Schema Registry +type SchemaRegistryId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string +} + +// NewSchemaRegistryID returns a new SchemaRegistryId struct +func NewSchemaRegistryID(subscriptionId string, resourceGroupName string, schemaRegistryName string) SchemaRegistryId { + return SchemaRegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + } +} + +// ParseSchemaRegistryID parses 'input' into a SchemaRegistryId +func ParseSchemaRegistryID(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaRegistryIDInsensitively parses 'input' case-insensitively into a SchemaRegistryId +// note: this method should only be used for API response data and not user input +func ParseSchemaRegistryIDInsensitively(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaRegistryId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + return nil +} + +// ValidateSchemaRegistryID checks that 'input' can be parsed as a Schema Registry ID +func ValidateSchemaRegistryID(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 := ParseSchemaRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Registry ID +func (id SchemaRegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Registry ID +func (id SchemaRegistryId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + } +} + +// String returns a human-readable description of this Schema Registry ID +func (id SchemaRegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + } + return fmt.Sprintf("Schema Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go new file mode 100644 index 00000000000..8513e452a58 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go @@ -0,0 +1,282 @@ +package schemaregistries + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +func TestNewSchemaRegistryID(t *testing.T) { + id := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } +} + +func TestFormatSchemaRegistryID(t *testing.T) { + actual := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestParseSchemaRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestSegmentsForSchemaRegistryId(t *testing.T) { + segments := SchemaRegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaRegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go new file mode 100644 index 00000000000..3e45cf4a1ad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go @@ -0,0 +1,75 @@ +package schemaregistries + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SchemaRegistry +} + +// CreateOrReplace ... +func (c SchemaRegistriesClient) CreateOrReplace(ctx context.Context, id SchemaRegistryId, input SchemaRegistry) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c SchemaRegistriesClient) CreateOrReplaceThenPoll(ctx context.Context, id SchemaRegistryId, input SchemaRegistry) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go new file mode 100644 index 00000000000..c2f7ca96918 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go @@ -0,0 +1,70 @@ +package schemaregistries + +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 SchemaRegistriesClient) Delete(ctx context.Context, id SchemaRegistryId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 SchemaRegistriesClient) DeleteThenPoll(ctx context.Context, id SchemaRegistryId) 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/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go new file mode 100644 index 00000000000..e11b4e0ea4f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go @@ -0,0 +1,53 @@ +package schemaregistries + +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 *SchemaRegistry +} + +// Get ... +func (c SchemaRegistriesClient) Get(ctx context.Context, id SchemaRegistryId) (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 SchemaRegistry + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0af59292908 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package schemaregistries + +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 *[]SchemaRegistry +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaRegistry +} + +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 SchemaRegistriesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/schemaRegistries", 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 *[]SchemaRegistry `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 SchemaRegistriesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SchemaRegistryOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaRegistriesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SchemaRegistryOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SchemaRegistry, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go new file mode 100644 index 00000000000..9e8f9a647ca --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go @@ -0,0 +1,106 @@ +package schemaregistries + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaRegistry +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaRegistry +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c SchemaRegistriesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/schemaRegistries", 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 *[]SchemaRegistry `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SchemaRegistriesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SchemaRegistryOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaRegistriesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SchemaRegistryOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SchemaRegistry, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go new file mode 100644 index 00000000000..8d6b780e207 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go @@ -0,0 +1,75 @@ +package schemaregistries + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SchemaRegistry +} + +// Update ... +func (c SchemaRegistriesClient) Update(ctx context.Context, id SchemaRegistryId, input SchemaRegistryUpdate) (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 SchemaRegistriesClient) UpdateThenPoll(ctx context.Context, id SchemaRegistryId, input SchemaRegistryUpdate) 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/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go new file mode 100644 index 00000000000..f52295b1227 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go @@ -0,0 +1,20 @@ +package schemaregistries + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "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 SchemaRegistry struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SchemaRegistryProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go new file mode 100644 index 00000000000..5a2bda1274c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go @@ -0,0 +1,13 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Namespace string `json:"namespace"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + StorageAccountContainerURL string `json:"storageAccountContainerUrl"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go new file mode 100644 index 00000000000..b231bfe45df --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go @@ -0,0 +1,14 @@ +package schemaregistries + +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 SchemaRegistryUpdate struct { + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Properties *SchemaRegistryUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go new file mode 100644 index 00000000000..704cf26ef7f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go @@ -0,0 +1,9 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryUpdateProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go new file mode 100644 index 00000000000..a6f3b796925 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go @@ -0,0 +1,32 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SchemaRegistryOperationPredicate) Matches(input SchemaRegistry) 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/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go new file mode 100644 index 00000000000..def85801165 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go @@ -0,0 +1,10 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemaregistries/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md new file mode 100644 index 00000000000..391e9da6e77 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemas` Documentation + +The `schemas` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/schemas" +``` + + +### Client Initialization + +```go +client := schemas.NewSchemasClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemasClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +payload := schemas.Schema{ + // ... +} + + +read, err := client.CreateOrReplace(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemasClient.Delete` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +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: `SchemasClient.Get` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +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: `SchemasClient.ListBySchemaRegistry` + +```go +ctx := context.TODO() +id := schemas.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +// alternatively `client.ListBySchemaRegistry(ctx, id)` can be used to do batched pagination +items, err := client.ListBySchemaRegistryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go new file mode 100644 index 00000000000..7929738b90e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go @@ -0,0 +1,26 @@ +package schemas + +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 SchemasClient struct { + Client *resourcemanager.Client +} + +func NewSchemasClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemasClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemas", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemasClient: %+v", err) + } + + return &SchemasClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go new file mode 100644 index 00000000000..7be0b1f5a0f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go @@ -0,0 +1,139 @@ +package schemas + +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 Format string + +const ( + FormatDeltaOnePointZero Format = "Delta/1.0" + FormatJsonSchemaDraftNegativeZeroSeven Format = "JsonSchema/draft-07" +) + +func PossibleValuesForFormat() []string { + return []string{ + string(FormatDeltaOnePointZero), + string(FormatJsonSchemaDraftNegativeZeroSeven), + } +} + +func (s *Format) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFormat(input string) (*Format, error) { + vals := map[string]Format{ + "delta/1.0": FormatDeltaOnePointZero, + "jsonschema/draft-07": FormatJsonSchemaDraftNegativeZeroSeven, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Format(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 SchemaType string + +const ( + SchemaTypeMessageSchema SchemaType = "MessageSchema" +) + +func PossibleValuesForSchemaType() []string { + return []string{ + string(SchemaTypeMessageSchema), + } +} + +func (s *SchemaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSchemaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSchemaType(input string) (*SchemaType, error) { + vals := map[string]SchemaType{ + "messageschema": SchemaTypeMessageSchema, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SchemaType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go new file mode 100644 index 00000000000..8b43dc42f96 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go @@ -0,0 +1,139 @@ +package schemas + +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(&SchemaId{}) +} + +var _ resourceids.ResourceId = &SchemaId{} + +// SchemaId is a struct representing the Resource ID for a Schema +type SchemaId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string +} + +// NewSchemaID returns a new SchemaId struct +func NewSchemaID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string) SchemaId { + return SchemaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + } +} + +// ParseSchemaID parses 'input' into a SchemaId +func ParseSchemaID(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaIDInsensitively parses 'input' case-insensitively into a SchemaId +// note: this method should only be used for API response data and not user input +func ParseSchemaIDInsensitively(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + return nil +} + +// ValidateSchemaID checks that 'input' can be parsed as a Schema ID +func ValidateSchemaID(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 := ParseSchemaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema ID +func (id SchemaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema ID +func (id SchemaId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + } +} + +// String returns a human-readable description of this Schema ID +func (id SchemaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + } + return fmt.Sprintf("Schema (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go new file mode 100644 index 00000000000..de76ffc1112 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go @@ -0,0 +1,327 @@ +package schemas + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SchemaId{} + +func TestNewSchemaID(t *testing.T) { + id := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } +} + +func TestFormatSchemaID(t *testing.T) { + actual := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestParseSchemaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestSegmentsForSchemaId(t *testing.T) { + segments := SchemaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go new file mode 100644 index 00000000000..ec782d4769d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go @@ -0,0 +1,130 @@ +package schemas + +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(&SchemaRegistryId{}) +} + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +// SchemaRegistryId is a struct representing the Resource ID for a Schema Registry +type SchemaRegistryId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string +} + +// NewSchemaRegistryID returns a new SchemaRegistryId struct +func NewSchemaRegistryID(subscriptionId string, resourceGroupName string, schemaRegistryName string) SchemaRegistryId { + return SchemaRegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + } +} + +// ParseSchemaRegistryID parses 'input' into a SchemaRegistryId +func ParseSchemaRegistryID(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaRegistryIDInsensitively parses 'input' case-insensitively into a SchemaRegistryId +// note: this method should only be used for API response data and not user input +func ParseSchemaRegistryIDInsensitively(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaRegistryId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + return nil +} + +// ValidateSchemaRegistryID checks that 'input' can be parsed as a Schema Registry ID +func ValidateSchemaRegistryID(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 := ParseSchemaRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Registry ID +func (id SchemaRegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Registry ID +func (id SchemaRegistryId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + } +} + +// String returns a human-readable description of this Schema Registry ID +func (id SchemaRegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + } + return fmt.Sprintf("Schema Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go new file mode 100644 index 00000000000..95a6c551695 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go @@ -0,0 +1,282 @@ +package schemas + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +func TestNewSchemaRegistryID(t *testing.T) { + id := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } +} + +func TestFormatSchemaRegistryID(t *testing.T) { + actual := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestParseSchemaRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestSegmentsForSchemaRegistryId(t *testing.T) { + segments := SchemaRegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaRegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go new file mode 100644 index 00000000000..6ee3b995452 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go @@ -0,0 +1,58 @@ +package schemas + +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 CreateOrReplaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Schema +} + +// CreateOrReplace ... +func (c SchemasClient) CreateOrReplace(ctx context.Context, id SchemaId, input Schema) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Schema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go new file mode 100644 index 00000000000..c9ad7d176ba --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go @@ -0,0 +1,47 @@ +package schemas + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SchemasClient) Delete(ctx context.Context, id SchemaId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go new file mode 100644 index 00000000000..6b039364518 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go @@ -0,0 +1,53 @@ +package schemas + +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 *Schema +} + +// Get ... +func (c SchemasClient) Get(ctx context.Context, id SchemaId) (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 Schema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go new file mode 100644 index 00000000000..cffb76c6865 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go @@ -0,0 +1,105 @@ +package schemas + +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 ListBySchemaRegistryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Schema +} + +type ListBySchemaRegistryCompleteResult struct { + LatestHttpResponse *http.Response + Items []Schema +} + +type ListBySchemaRegistryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySchemaRegistryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySchemaRegistry ... +func (c SchemasClient) ListBySchemaRegistry(ctx context.Context, id SchemaRegistryId) (result ListBySchemaRegistryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySchemaRegistryCustomPager{}, + Path: fmt.Sprintf("%s/schemas", 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 *[]Schema `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySchemaRegistryComplete retrieves all the results into a single object +func (c SchemasClient) ListBySchemaRegistryComplete(ctx context.Context, id SchemaRegistryId) (ListBySchemaRegistryCompleteResult, error) { + return c.ListBySchemaRegistryCompleteMatchingPredicate(ctx, id, SchemaOperationPredicate{}) +} + +// ListBySchemaRegistryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemasClient) ListBySchemaRegistryCompleteMatchingPredicate(ctx context.Context, id SchemaRegistryId, predicate SchemaOperationPredicate) (result ListBySchemaRegistryCompleteResult, err error) { + items := make([]Schema, 0) + + resp, err := c.ListBySchemaRegistry(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 = ListBySchemaRegistryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go new file mode 100644 index 00000000000..3ddea4bb519 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go @@ -0,0 +1,16 @@ +package schemas + +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 Schema struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SchemaProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go new file mode 100644 index 00000000000..2e330ea6c87 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go @@ -0,0 +1,14 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Format Format `json:"format"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SchemaType SchemaType `json:"schemaType"` + Tags *map[string]string `json:"tags,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go new file mode 100644 index 00000000000..4c9a2d16acc --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go @@ -0,0 +1,27 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SchemaOperationPredicate) Matches(input Schema) 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/resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go new file mode 100644 index 00000000000..a2008ffb20e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go @@ -0,0 +1,10 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemas/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md new file mode 100644 index 00000000000..84c56207b78 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaversions` Documentation + +The `schemaversions` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-09-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/deviceregistry/2024-09-01-preview/schemaversions" +``` + + +### Client Initialization + +```go +client := schemaversions.NewSchemaVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemaVersionsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +payload := schemaversions.SchemaVersion{ + // ... +} + + +read, err := client.CreateOrReplace(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemaVersionsClient.Delete` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +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: `SchemaVersionsClient.Get` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +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: `SchemaVersionsClient.ListBySchema` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +// alternatively `client.ListBySchema(ctx, id)` can be used to do batched pagination +items, err := client.ListBySchemaComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go new file mode 100644 index 00000000000..7a4ed03f49d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go @@ -0,0 +1,26 @@ +package schemaversions + +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 SchemaVersionsClient struct { + Client *resourcemanager.Client +} + +func NewSchemaVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemaVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemaversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaVersionsClient: %+v", err) + } + + return &SchemaVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go new file mode 100644 index 00000000000..830af71bdac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go @@ -0,0 +1,60 @@ +package schemaversions + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + 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{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "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 +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go new file mode 100644 index 00000000000..4f7df69aba7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go @@ -0,0 +1,139 @@ +package schemaversions + +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(&SchemaId{}) +} + +var _ resourceids.ResourceId = &SchemaId{} + +// SchemaId is a struct representing the Resource ID for a Schema +type SchemaId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string +} + +// NewSchemaID returns a new SchemaId struct +func NewSchemaID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string) SchemaId { + return SchemaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + } +} + +// ParseSchemaID parses 'input' into a SchemaId +func ParseSchemaID(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaIDInsensitively parses 'input' case-insensitively into a SchemaId +// note: this method should only be used for API response data and not user input +func ParseSchemaIDInsensitively(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + return nil +} + +// ValidateSchemaID checks that 'input' can be parsed as a Schema ID +func ValidateSchemaID(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 := ParseSchemaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema ID +func (id SchemaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema ID +func (id SchemaId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + } +} + +// String returns a human-readable description of this Schema ID +func (id SchemaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + } + return fmt.Sprintf("Schema (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go new file mode 100644 index 00000000000..9572716c2fa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go @@ -0,0 +1,327 @@ +package schemaversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SchemaId{} + +func TestNewSchemaID(t *testing.T) { + id := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } +} + +func TestFormatSchemaID(t *testing.T) { + actual := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestParseSchemaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestSegmentsForSchemaId(t *testing.T) { + segments := SchemaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go new file mode 100644 index 00000000000..70eade4e0b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go @@ -0,0 +1,148 @@ +package schemaversions + +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(&SchemaVersionId{}) +} + +var _ resourceids.ResourceId = &SchemaVersionId{} + +// SchemaVersionId is a struct representing the Resource ID for a Schema Version +type SchemaVersionId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string + SchemaVersionName string +} + +// NewSchemaVersionID returns a new SchemaVersionId struct +func NewSchemaVersionID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string, schemaVersionName string) SchemaVersionId { + return SchemaVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + SchemaVersionName: schemaVersionName, + } +} + +// ParseSchemaVersionID parses 'input' into a SchemaVersionId +func ParseSchemaVersionID(input string) (*SchemaVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaVersionIDInsensitively parses 'input' case-insensitively into a SchemaVersionId +// note: this method should only be used for API response data and not user input +func ParseSchemaVersionIDInsensitively(input string) (*SchemaVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaVersionId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + if id.SchemaVersionName, ok = input.Parsed["schemaVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaVersionName", input) + } + + return nil +} + +// ValidateSchemaVersionID checks that 'input' can be parsed as a Schema Version ID +func ValidateSchemaVersionID(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 := ParseSchemaVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Version ID +func (id SchemaVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s/schemaVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName, id.SchemaVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Version ID +func (id SchemaVersionId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + resourceids.StaticSegment("staticSchemaVersions", "schemaVersions", "schemaVersions"), + resourceids.UserSpecifiedSegment("schemaVersionName", "schemaVersionName"), + } +} + +// String returns a human-readable description of this Schema Version ID +func (id SchemaVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + fmt.Sprintf("Schema Version Name: %q", id.SchemaVersionName), + } + return fmt.Sprintf("Schema Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go new file mode 100644 index 00000000000..ad48686ff03 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go @@ -0,0 +1,372 @@ +package schemaversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SchemaVersionId{} + +func TestNewSchemaVersionID(t *testing.T) { + id := NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } + + if id.SchemaVersionName != "schemaVersionName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaVersionName'", id.SchemaVersionName, "schemaVersionName") + } +} + +func TestFormatSchemaVersionID(t *testing.T) { + actual := NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + SchemaVersionName: "schemaVersionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + if actual.SchemaVersionName != v.Expected.SchemaVersionName { + t.Fatalf("Expected %q but got %q for SchemaVersionName", v.Expected.SchemaVersionName, actual.SchemaVersionName) + } + + } +} + +func TestParseSchemaVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + SchemaVersionName: "schemaVersionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS/sChEmAvErSiOnNaMe", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + SchemaVersionName: "sChEmAvErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS/sChEmAvErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + if actual.SchemaVersionName != v.Expected.SchemaVersionName { + t.Fatalf("Expected %q but got %q for SchemaVersionName", v.Expected.SchemaVersionName, actual.SchemaVersionName) + } + + } +} + +func TestSegmentsForSchemaVersionId(t *testing.T) { + segments := SchemaVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go new file mode 100644 index 00000000000..b8602a9a5e7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go @@ -0,0 +1,58 @@ +package schemaversions + +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 CreateOrReplaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SchemaVersion +} + +// CreateOrReplace ... +func (c SchemaVersionsClient) CreateOrReplace(ctx context.Context, id SchemaVersionId, input SchemaVersion) (result CreateOrReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SchemaVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go new file mode 100644 index 00000000000..370ff70ebaa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go @@ -0,0 +1,47 @@ +package schemaversions + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SchemaVersionsClient) Delete(ctx context.Context, id SchemaVersionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go new file mode 100644 index 00000000000..7ca9e62d750 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go @@ -0,0 +1,53 @@ +package schemaversions + +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 *SchemaVersion +} + +// Get ... +func (c SchemaVersionsClient) Get(ctx context.Context, id SchemaVersionId) (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 SchemaVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go new file mode 100644 index 00000000000..5ec1fac8903 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go @@ -0,0 +1,105 @@ +package schemaversions + +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 ListBySchemaOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaVersion +} + +type ListBySchemaCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaVersion +} + +type ListBySchemaCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySchemaCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySchema ... +func (c SchemaVersionsClient) ListBySchema(ctx context.Context, id SchemaId) (result ListBySchemaOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySchemaCustomPager{}, + Path: fmt.Sprintf("%s/schemaVersions", 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 *[]SchemaVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySchemaComplete retrieves all the results into a single object +func (c SchemaVersionsClient) ListBySchemaComplete(ctx context.Context, id SchemaId) (ListBySchemaCompleteResult, error) { + return c.ListBySchemaCompleteMatchingPredicate(ctx, id, SchemaVersionOperationPredicate{}) +} + +// ListBySchemaCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaVersionsClient) ListBySchemaCompleteMatchingPredicate(ctx context.Context, id SchemaId, predicate SchemaVersionOperationPredicate) (result ListBySchemaCompleteResult, err error) { + items := make([]SchemaVersion, 0) + + resp, err := c.ListBySchema(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 = ListBySchemaCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go new file mode 100644 index 00000000000..ec1400fe34b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go @@ -0,0 +1,16 @@ +package schemaversions + +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 SchemaVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SchemaVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go new file mode 100644 index 00000000000..62cc1c3b58a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go @@ -0,0 +1,12 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaVersionProperties struct { + Description *string `json:"description,omitempty"` + Hash *string `json:"hash,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SchemaContent string `json:"schemaContent"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go new file mode 100644 index 00000000000..7d1db6450f9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go @@ -0,0 +1,27 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SchemaVersionOperationPredicate) Matches(input SchemaVersion) 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/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go new file mode 100644 index 00000000000..900ebe05bc4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go @@ -0,0 +1,10 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemaversions/2024-09-01-preview" +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md new file mode 100644 index 00000000000..9f7d761d0a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/availableservicetiers` Documentation + +The `availableservicetiers` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/availableservicetiers" +``` + + +### Client Initialization + +```go +client := availableservicetiers.NewAvailableServiceTiersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailableServiceTiersClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := availableservicetiers.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go new file mode 100644 index 00000000000..3396efc04c9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go @@ -0,0 +1,26 @@ +package availableservicetiers + +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 AvailableServiceTiersClient struct { + Client *resourcemanager.Client +} + +func NewAvailableServiceTiersClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailableServiceTiersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "availableservicetiers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailableServiceTiersClient: %+v", err) + } + + return &AvailableServiceTiersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go new file mode 100644 index 00000000000..26729cec9cc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go @@ -0,0 +1,66 @@ +package availableservicetiers + +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 SkuNameEnum string + +const ( + SkuNameEnumCapacityReservation SkuNameEnum = "CapacityReservation" + SkuNameEnumFree SkuNameEnum = "Free" + SkuNameEnumPerGBTwoZeroOneEight SkuNameEnum = "PerGB2018" + SkuNameEnumPerNode SkuNameEnum = "PerNode" + SkuNameEnumPremium SkuNameEnum = "Premium" + SkuNameEnumStandalone SkuNameEnum = "Standalone" + SkuNameEnumStandard SkuNameEnum = "Standard" +) + +func PossibleValuesForSkuNameEnum() []string { + return []string{ + string(SkuNameEnumCapacityReservation), + string(SkuNameEnumFree), + string(SkuNameEnumPerGBTwoZeroOneEight), + string(SkuNameEnumPerNode), + string(SkuNameEnumPremium), + string(SkuNameEnumStandalone), + string(SkuNameEnumStandard), + } +} + +func (s *SkuNameEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuNameEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuNameEnum(input string) (*SkuNameEnum, error) { + vals := map[string]SkuNameEnum{ + "capacityreservation": SkuNameEnumCapacityReservation, + "free": SkuNameEnumFree, + "pergb2018": SkuNameEnumPerGBTwoZeroOneEight, + "pernode": SkuNameEnumPerNode, + "premium": SkuNameEnumPremium, + "standalone": SkuNameEnumStandalone, + "standard": SkuNameEnumStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuNameEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go new file mode 100644 index 00000000000..4600980eb71 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go @@ -0,0 +1,130 @@ +package availableservicetiers + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go new file mode 100644 index 00000000000..34b0b9e1f18 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go @@ -0,0 +1,282 @@ +package availableservicetiers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go new file mode 100644 index 00000000000..431f2b6767c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package availableservicetiers + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableServiceTier +} + +// ListByWorkspace ... +func (c AvailableServiceTiersClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availableServiceTiers", 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 []AvailableServiceTier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go new file mode 100644 index 00000000000..b41b7f9b19a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go @@ -0,0 +1,14 @@ +package availableservicetiers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableServiceTier struct { + CapacityReservationLevel *int64 `json:"capacityReservationLevel,omitempty"` + DefaultRetention *int64 `json:"defaultRetention,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` + MaximumRetention *int64 `json:"maximumRetention,omitempty"` + MinimumRetention *int64 `json:"minimumRetention,omitempty"` + ServiceTier *SkuNameEnum `json:"serviceTier,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go new file mode 100644 index 00000000000..652caae04e9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go @@ -0,0 +1,10 @@ +package availableservicetiers + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/availableservicetiers/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/client.go b/resource-manager/operationalinsights/2023-09-01/client.go index f32d4eeb2bf..b98bb5ea557 100644 --- a/resource-manager/operationalinsights/2023-09-01/client.go +++ b/resource-manager/operationalinsights/2023-09-01/client.go @@ -6,24 +6,120 @@ package v2023_09_01 import ( "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/availableservicetiers" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/dataexport" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/datasources" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/deletedworkspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/intelligencepacks" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypackqueries" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/savedsearches" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/storageinsights" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/tables" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/workspaces" "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { - DeletedWorkspaces *deletedworkspaces.DeletedWorkspacesClient - Workspaces *workspaces.WorkspacesClient + AvailableServiceTiers *availableservicetiers.AvailableServiceTiersClient + Clusters *clusters.ClustersClient + DataExport *dataexport.DataExportClient + DataSources *datasources.DataSourcesClient + DeletedWorkspaces *deletedworkspaces.DeletedWorkspacesClient + IntelligencePacks *intelligencepacks.IntelligencePacksClient + LinkedServices *linkedservices.LinkedServicesClient + LinkedStorageAccounts *linkedstorageaccounts.LinkedStorageAccountsClient + QueryPackQueries *querypackqueries.QueryPackQueriesClient + QueryPacks *querypacks.QueryPacksClient + SavedSearches *savedsearches.SavedSearchesClient + StorageInsights *storageinsights.StorageInsightsClient + Tables *tables.TablesClient + Workspaces *workspaces.WorkspacesClient } func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + availableServiceTiersClient, err := availableservicetiers.NewAvailableServiceTiersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailableServiceTiers client: %+v", err) + } + configureFunc(availableServiceTiersClient.Client) + + clustersClient, err := clusters.NewClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Clusters client: %+v", err) + } + configureFunc(clustersClient.Client) + + dataExportClient, err := dataexport.NewDataExportClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataExport client: %+v", err) + } + configureFunc(dataExportClient.Client) + + dataSourcesClient, err := datasources.NewDataSourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataSources client: %+v", err) + } + configureFunc(dataSourcesClient.Client) + deletedWorkspacesClient, err := deletedworkspaces.NewDeletedWorkspacesClientWithBaseURI(sdkApi) if err != nil { return nil, fmt.Errorf("building DeletedWorkspaces client: %+v", err) } configureFunc(deletedWorkspacesClient.Client) + intelligencePacksClient, err := intelligencepacks.NewIntelligencePacksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building IntelligencePacks client: %+v", err) + } + configureFunc(intelligencePacksClient.Client) + + linkedServicesClient, err := linkedservices.NewLinkedServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LinkedServices client: %+v", err) + } + configureFunc(linkedServicesClient.Client) + + linkedStorageAccountsClient, err := linkedstorageaccounts.NewLinkedStorageAccountsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LinkedStorageAccounts client: %+v", err) + } + configureFunc(linkedStorageAccountsClient.Client) + + queryPackQueriesClient, err := querypackqueries.NewQueryPackQueriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryPackQueries client: %+v", err) + } + configureFunc(queryPackQueriesClient.Client) + + queryPacksClient, err := querypacks.NewQueryPacksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryPacks client: %+v", err) + } + configureFunc(queryPacksClient.Client) + + savedSearchesClient, err := savedsearches.NewSavedSearchesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SavedSearches client: %+v", err) + } + configureFunc(savedSearchesClient.Client) + + storageInsightsClient, err := storageinsights.NewStorageInsightsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StorageInsights client: %+v", err) + } + configureFunc(storageInsightsClient.Client) + + tablesClient, err := tables.NewTablesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Tables client: %+v", err) + } + configureFunc(tablesClient.Client) + workspacesClient, err := workspaces.NewWorkspacesClientWithBaseURI(sdkApi) if err != nil { return nil, fmt.Errorf("building Workspaces client: %+v", err) @@ -31,7 +127,19 @@ func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanag configureFunc(workspacesClient.Client) return &Client{ - DeletedWorkspaces: deletedWorkspacesClient, - Workspaces: workspacesClient, + AvailableServiceTiers: availableServiceTiersClient, + Clusters: clustersClient, + DataExport: dataExportClient, + DataSources: dataSourcesClient, + DeletedWorkspaces: deletedWorkspacesClient, + IntelligencePacks: intelligencePacksClient, + LinkedServices: linkedServicesClient, + LinkedStorageAccounts: linkedStorageAccountsClient, + QueryPackQueries: queryPackQueriesClient, + QueryPacks: queryPacksClient, + SavedSearches: savedSearchesClient, + StorageInsights: storageInsightsClient, + Tables: tablesClient, + Workspaces: workspacesClient, }, nil } diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/README.md b/resource-manager/operationalinsights/2023-09-01/clusters/README.md new file mode 100644 index 00000000000..80011c33cb9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters` Documentation + +The `clusters` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters" +``` + + +### Client Initialization + +```go +client := clusters.NewClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.Cluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Delete` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Get` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +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: `ClustersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.Update` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.ClusterPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/client.go b/resource-manager/operationalinsights/2023-09-01/clusters/client.go new file mode 100644 index 00000000000..4ead092b486 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/client.go @@ -0,0 +1,26 @@ +package clusters + +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 ClustersClient struct { + Client *resourcemanager.Client +} + +func NewClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClustersClient: %+v", err) + } + + return &ClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/constants.go b/resource-manager/operationalinsights/2023-09-01/clusters/constants.go new file mode 100644 index 00000000000..8cc74416a55 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/constants.go @@ -0,0 +1,177 @@ +package clusters + +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 BillingType string + +const ( + BillingTypeCluster BillingType = "Cluster" + BillingTypeWorkspaces BillingType = "Workspaces" +) + +func PossibleValuesForBillingType() []string { + return []string{ + string(BillingTypeCluster), + string(BillingTypeWorkspaces), + } +} + +func (s *BillingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingType(input string) (*BillingType, error) { + vals := map[string]BillingType{ + "cluster": BillingTypeCluster, + "workspaces": BillingTypeWorkspaces, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingType(input) + return &out, nil +} + +type Capacity int64 + +const ( + CapacityFiveHundred Capacity = 500 + CapacityFiveThousand Capacity = 5000 + CapacityFiveZeroThousand Capacity = 50000 + CapacityFourHundred Capacity = 400 + CapacityOneHundred Capacity = 100 + CapacityOneThousand Capacity = 1000 + CapacityOneZeroThousand Capacity = 10000 + CapacityThreeHundred Capacity = 300 + CapacityTwoFiveThousand Capacity = 25000 + CapacityTwoHundred Capacity = 200 + CapacityTwoThousand Capacity = 2000 +) + +func PossibleValuesForCapacity() []int64 { + return []int64{ + int64(CapacityFiveHundred), + int64(CapacityFiveThousand), + int64(CapacityFiveZeroThousand), + int64(CapacityFourHundred), + int64(CapacityOneHundred), + int64(CapacityOneThousand), + int64(CapacityOneZeroThousand), + int64(CapacityThreeHundred), + int64(CapacityTwoFiveThousand), + int64(CapacityTwoHundred), + int64(CapacityTwoThousand), + } +} + +type ClusterEntityStatus string + +const ( + ClusterEntityStatusCanceled ClusterEntityStatus = "Canceled" + ClusterEntityStatusCreating ClusterEntityStatus = "Creating" + ClusterEntityStatusDeleting ClusterEntityStatus = "Deleting" + ClusterEntityStatusFailed ClusterEntityStatus = "Failed" + ClusterEntityStatusProvisioningAccount ClusterEntityStatus = "ProvisioningAccount" + ClusterEntityStatusSucceeded ClusterEntityStatus = "Succeeded" + ClusterEntityStatusUpdating ClusterEntityStatus = "Updating" +) + +func PossibleValuesForClusterEntityStatus() []string { + return []string{ + string(ClusterEntityStatusCanceled), + string(ClusterEntityStatusCreating), + string(ClusterEntityStatusDeleting), + string(ClusterEntityStatusFailed), + string(ClusterEntityStatusProvisioningAccount), + string(ClusterEntityStatusSucceeded), + string(ClusterEntityStatusUpdating), + } +} + +func (s *ClusterEntityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterEntityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterEntityStatus(input string) (*ClusterEntityStatus, error) { + vals := map[string]ClusterEntityStatus{ + "canceled": ClusterEntityStatusCanceled, + "creating": ClusterEntityStatusCreating, + "deleting": ClusterEntityStatusDeleting, + "failed": ClusterEntityStatusFailed, + "provisioningaccount": ClusterEntityStatusProvisioningAccount, + "succeeded": ClusterEntityStatusSucceeded, + "updating": ClusterEntityStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterEntityStatus(input) + return &out, nil +} + +type ClusterSkuNameEnum string + +const ( + ClusterSkuNameEnumCapacityReservation ClusterSkuNameEnum = "CapacityReservation" +) + +func PossibleValuesForClusterSkuNameEnum() []string { + return []string{ + string(ClusterSkuNameEnumCapacityReservation), + } +} + +func (s *ClusterSkuNameEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterSkuNameEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterSkuNameEnum(input string) (*ClusterSkuNameEnum, error) { + vals := map[string]ClusterSkuNameEnum{ + "capacityreservation": ClusterSkuNameEnumCapacityReservation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterSkuNameEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go new file mode 100644 index 00000000000..0bb42eab67c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go @@ -0,0 +1,130 @@ +package clusters + +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(&ClusterId{}) +} + +var _ resourceids.ResourceId = &ClusterId{} + +// ClusterId is a struct representing the Resource ID for a Cluster +type ClusterId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string +} + +// NewClusterID returns a new ClusterId struct +func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { + return ClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + } +} + +// ParseClusterID parses 'input' into a ClusterId +func ParseClusterID(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId +// note: this method should only be used for API response data and not user input +func ParseClusterIDInsensitively(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClusterId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + return nil +} + +// ValidateClusterID checks that 'input' can be parsed as a Cluster ID +func ValidateClusterID(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 := ParseClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cluster ID +func (id ClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/clusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cluster ID +func (id ClusterId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + } +} + +// String returns a human-readable description of this Cluster ID +func (id ClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + } + return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go new file mode 100644 index 00000000000..c450b8197c7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go @@ -0,0 +1,282 @@ +package clusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ClusterId{} + +func TestNewClusterID(t *testing.T) { + id := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } +} + +func TestFormatClusterID(t *testing.T) { + actual := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestParseClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/cLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/cLuStErS/cLuStErNaMe", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/cLuStErS/cLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestSegmentsForClusterId(t *testing.T) { + segments := ClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go new file mode 100644 index 00000000000..92394c4deb4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go @@ -0,0 +1,76 @@ +package clusters + +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 *Cluster +} + +// CreateOrUpdate ... +func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (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 ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) 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/resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go new file mode 100644 index 00000000000..13e2610ffd6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go @@ -0,0 +1,71 @@ +package clusters + +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 ClustersClient) Delete(ctx context.Context, id ClusterId) (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 ClustersClient) DeleteThenPoll(ctx context.Context, id ClusterId) 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/resource-manager/operationalinsights/2023-09-01/clusters/method_get.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_get.go new file mode 100644 index 00000000000..8265f74e863 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_get.go @@ -0,0 +1,53 @@ +package clusters + +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 *Cluster +} + +// Get ... +func (c ClustersClient) Get(ctx context.Context, id ClusterId) (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 Cluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go new file mode 100644 index 00000000000..84041722337 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go @@ -0,0 +1,106 @@ +package clusters + +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 *[]Cluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +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 ClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", 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 *[]Cluster `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 ClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..2bd22023e91 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package clusters + +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 *[]Cluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +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 ClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", 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 *[]Cluster `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 ClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go new file mode 100644 index 00000000000..f11774e7c12 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go @@ -0,0 +1,74 @@ +package clusters + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Cluster +} + +// Update ... +func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) 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/resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go new file mode 100644 index 00000000000..ad5986522e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssociatedWorkspace struct { + AssociateDate *string `json:"associateDate,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceName *string `json:"workspaceName,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go new file mode 100644 index 00000000000..2e65bfb192f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityReservationProperties struct { + LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go new file mode 100644 index 00000000000..be303015217 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go @@ -0,0 +1,19 @@ +package clusters + +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 Cluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ClusterProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go new file mode 100644 index 00000000000..9524c09d0bc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go @@ -0,0 +1,15 @@ +package clusters + +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 ClusterPatch struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ClusterPatchProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go new file mode 100644 index 00000000000..7960ea89b28 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPatchProperties struct { + BillingType *BillingType `json:"billingType,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go new file mode 100644 index 00000000000..36f519cd0d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go @@ -0,0 +1,17 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterProperties struct { + AssociatedWorkspaces *[]AssociatedWorkspace `json:"associatedWorkspaces,omitempty"` + BillingType *BillingType `json:"billingType,omitempty"` + CapacityReservationProperties *CapacityReservationProperties `json:"capacityReservationProperties,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + CreatedDate *string `json:"createdDate,omitempty"` + IsAvailabilityZonesEnabled *bool `json:"isAvailabilityZonesEnabled,omitempty"` + IsDoubleEncryptionEnabled *bool `json:"isDoubleEncryptionEnabled,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` + ProvisioningState *ClusterEntityStatus `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go new file mode 100644 index 00000000000..6f279c158d7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterSku struct { + Capacity *Capacity `json:"capacity,omitempty"` + Name *ClusterSkuNameEnum `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go new file mode 100644 index 00000000000..b2cfa77b7d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName *string `json:"keyName,omitempty"` + KeyRsaSize *int64 `json:"keyRsaSize,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go b/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go new file mode 100644 index 00000000000..cc13b7c6220 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go @@ -0,0 +1,32 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterOperationPredicate) Matches(input Cluster) 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/resource-manager/operationalinsights/2023-09-01/clusters/version.go b/resource-manager/operationalinsights/2023-09-01/clusters/version.go new file mode 100644 index 00000000000..322b9e7b925 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/version.go @@ -0,0 +1,10 @@ +package clusters + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusters/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/README.md b/resource-manager/operationalinsights/2023-09-01/dataexport/README.md new file mode 100644 index 00000000000..58b96ca43e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/dataexport` Documentation + +The `dataexport` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/dataexport" +``` + + +### Client Initialization + +```go +client := dataexport.NewDataExportClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataExportClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +payload := dataexport.DataExport{ + // ... +} + + +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: `DataExportClient.Delete` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +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: `DataExportClient.Get` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +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: `DataExportClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := dataexport.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/client.go b/resource-manager/operationalinsights/2023-09-01/dataexport/client.go new file mode 100644 index 00000000000..5113e66d9c0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/client.go @@ -0,0 +1,26 @@ +package dataexport + +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 DataExportClient struct { + Client *resourcemanager.Client +} + +func NewDataExportClientWithBaseURI(sdkApi sdkEnv.Api) (*DataExportClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dataexport", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataExportClient: %+v", err) + } + + return &DataExportClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go b/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go new file mode 100644 index 00000000000..c103dc9f1ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go @@ -0,0 +1,51 @@ +package dataexport + +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 Type string + +const ( + TypeEventHub Type = "EventHub" + TypeStorageAccount Type = "StorageAccount" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeEventHub), + string(TypeStorageAccount), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "eventhub": TypeEventHub, + "storageaccount": TypeStorageAccount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go new file mode 100644 index 00000000000..a8de549cff8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go @@ -0,0 +1,139 @@ +package dataexport + +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(&DataExportId{}) +} + +var _ resourceids.ResourceId = &DataExportId{} + +// DataExportId is a struct representing the Resource ID for a Data Export +type DataExportId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataExportName string +} + +// NewDataExportID returns a new DataExportId struct +func NewDataExportID(subscriptionId string, resourceGroupName string, workspaceName string, dataExportName string) DataExportId { + return DataExportId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataExportName: dataExportName, + } +} + +// ParseDataExportID parses 'input' into a DataExportId +func ParseDataExportID(input string) (*DataExportId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataExportId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataExportId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataExportIDInsensitively parses 'input' case-insensitively into a DataExportId +// note: this method should only be used for API response data and not user input +func ParseDataExportIDInsensitively(input string) (*DataExportId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataExportId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataExportId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataExportId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataExportName, ok = input.Parsed["dataExportName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataExportName", input) + } + + return nil +} + +// ValidateDataExportID checks that 'input' can be parsed as a Data Export ID +func ValidateDataExportID(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 := ParseDataExportID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Export ID +func (id DataExportId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataExports/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataExportName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Export ID +func (id DataExportId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticDataExports", "dataExports", "dataExports"), + resourceids.UserSpecifiedSegment("dataExportName", "dataExportName"), + } +} + +// String returns a human-readable description of this Data Export ID +func (id DataExportId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Export Name: %q", id.DataExportName), + } + return fmt.Sprintf("Data Export (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go new file mode 100644 index 00000000000..d88423d09bc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go @@ -0,0 +1,327 @@ +package dataexport + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataExportId{} + +func TestNewDataExportID(t *testing.T) { + id := NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataExportName != "dataExportName" { + t.Fatalf("Expected %q but got %q for Segment 'DataExportName'", id.DataExportName, "dataExportName") + } +} + +func TestFormatDataExportID(t *testing.T) { + actual := NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataExportID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataExportId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataExportName: "dataExportName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataExportID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataExportName != v.Expected.DataExportName { + t.Fatalf("Expected %q but got %q for DataExportName", v.Expected.DataExportName, actual.DataExportName) + } + + } +} + +func TestParseDataExportIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataExportId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataExportName: "dataExportName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs/dAtAeXpOrTnAmE", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataExportName: "dAtAeXpOrTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs/dAtAeXpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataExportIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataExportName != v.Expected.DataExportName { + t.Fatalf("Expected %q but got %q for DataExportName", v.Expected.DataExportName, actual.DataExportName) + } + + } +} + +func TestSegmentsForDataExportId(t *testing.T) { + segments := DataExportId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataExportId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go new file mode 100644 index 00000000000..c2506a768f9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go @@ -0,0 +1,130 @@ +package dataexport + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go new file mode 100644 index 00000000000..5373c883c57 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go @@ -0,0 +1,282 @@ +package dataexport + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go new file mode 100644 index 00000000000..6715bd687d9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go @@ -0,0 +1,58 @@ +package dataexport + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataExport +} + +// CreateOrUpdate ... +func (c DataExportClient) CreateOrUpdate(ctx context.Context, id DataExportId, input DataExport) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DataExport + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go new file mode 100644 index 00000000000..0955b9b73ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go @@ -0,0 +1,46 @@ +package dataexport + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DataExportClient) Delete(ctx context.Context, id DataExportId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go new file mode 100644 index 00000000000..31181e61127 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go @@ -0,0 +1,53 @@ +package dataexport + +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 *DataExport +} + +// Get ... +func (c DataExportClient) Get(ctx context.Context, id DataExportId) (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 DataExport + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go new file mode 100644 index 00000000000..aa783d2a041 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package dataexport + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataExportListResult +} + +// ListByWorkspace ... +func (c DataExportClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataExports", 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 DataExportListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go new file mode 100644 index 00000000000..b7f7ca1ec04 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go @@ -0,0 +1,11 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExport struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DataExportProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go new file mode 100644 index 00000000000..0944681ef9d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go @@ -0,0 +1,8 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExportListResult struct { + Value *[]DataExport `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go new file mode 100644 index 00000000000..f3677b9395d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go @@ -0,0 +1,13 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExportProperties struct { + CreatedDate *string `json:"createdDate,omitempty"` + DataExportId *string `json:"dataExportId,omitempty"` + Destination *Destination `json:"destination,omitempty"` + Enable *bool `json:"enable,omitempty"` + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` + TableNames []string `json:"tableNames"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go new file mode 100644 index 00000000000..534e7081b71 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go @@ -0,0 +1,10 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Destination struct { + MetaData *DestinationMetaData `json:"metaData,omitempty"` + ResourceId string `json:"resourceId"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go new file mode 100644 index 00000000000..abf5e37918e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go @@ -0,0 +1,8 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationMetaData struct { + EventHubName *string `json:"eventHubName,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/version.go b/resource-manager/operationalinsights/2023-09-01/dataexport/version.go new file mode 100644 index 00000000000..0b8284c7976 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/version.go @@ -0,0 +1,10 @@ +package dataexport + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dataexport/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/README.md b/resource-manager/operationalinsights/2023-09-01/datasources/README.md new file mode 100644 index 00000000000..a0f1ce4ccaf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/datasources` Documentation + +The `datasources` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/datasources" +``` + + +### Client Initialization + +```go +client := datasources.NewDataSourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataSourcesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +payload := datasources.DataSource{ + // ... +} + + +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: `DataSourcesClient.Delete` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +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: `DataSourcesClient.Get` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +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: `DataSourcesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := datasources.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.ListByWorkspace(ctx, id, datasources.DefaultListByWorkspaceOperationOptions())` can be used to do batched pagination +items, err := client.ListByWorkspaceComplete(ctx, id, datasources.DefaultListByWorkspaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/client.go b/resource-manager/operationalinsights/2023-09-01/datasources/client.go new file mode 100644 index 00000000000..ab9ec31dddc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/client.go @@ -0,0 +1,26 @@ +package datasources + +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 DataSourcesClient struct { + Client *resourcemanager.Client +} + +func NewDataSourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*DataSourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datasources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataSourcesClient: %+v", err) + } + + return &DataSourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/constants.go b/resource-manager/operationalinsights/2023-09-01/datasources/constants.go new file mode 100644 index 00000000000..91241eeca9f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/constants.go @@ -0,0 +1,144 @@ +package datasources + +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 DataSourceKind string + +const ( + DataSourceKindApplicationInsights DataSourceKind = "ApplicationInsights" + DataSourceKindAzureActivityLog DataSourceKind = "AzureActivityLog" + DataSourceKindAzureAuditLog DataSourceKind = "AzureAuditLog" + DataSourceKindChangeTrackingContentLocation DataSourceKind = "ChangeTrackingContentLocation" + DataSourceKindChangeTrackingCustomPath DataSourceKind = "ChangeTrackingCustomPath" + DataSourceKindChangeTrackingDataTypeConfiguration DataSourceKind = "ChangeTrackingDataTypeConfiguration" + DataSourceKindChangeTrackingDefaultRegistry DataSourceKind = "ChangeTrackingDefaultRegistry" + DataSourceKindChangeTrackingLinuxPath DataSourceKind = "ChangeTrackingLinuxPath" + DataSourceKindChangeTrackingPath DataSourceKind = "ChangeTrackingPath" + DataSourceKindChangeTrackingRegistry DataSourceKind = "ChangeTrackingRegistry" + DataSourceKindChangeTrackingServices DataSourceKind = "ChangeTrackingServices" + DataSourceKindCustomLog DataSourceKind = "CustomLog" + DataSourceKindCustomLogCollection DataSourceKind = "CustomLogCollection" + DataSourceKindDnsAnalytics DataSourceKind = "DnsAnalytics" + DataSourceKindGenericDataSource DataSourceKind = "GenericDataSource" + DataSourceKindIISLogs DataSourceKind = "IISLogs" + DataSourceKindImportComputerGroup DataSourceKind = "ImportComputerGroup" + DataSourceKindItsm DataSourceKind = "Itsm" + DataSourceKindLinuxChangeTrackingPath DataSourceKind = "LinuxChangeTrackingPath" + DataSourceKindLinuxPerformanceCollection DataSourceKind = "LinuxPerformanceCollection" + DataSourceKindLinuxPerformanceObject DataSourceKind = "LinuxPerformanceObject" + DataSourceKindLinuxSyslog DataSourceKind = "LinuxSyslog" + DataSourceKindLinuxSyslogCollection DataSourceKind = "LinuxSyslogCollection" + DataSourceKindNetworkMonitoring DataSourceKind = "NetworkMonitoring" + DataSourceKindOfficeThreeSixFive DataSourceKind = "Office365" + DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityCenterSecurityWindowsBaselineConfiguration" + DataSourceKindSecurityEventCollectionConfiguration DataSourceKind = "SecurityEventCollectionConfiguration" + DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration DataSourceKind = "SecurityInsightsSecurityEventCollectionConfiguration" + DataSourceKindSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityWindowsBaselineConfiguration" + DataSourceKindSqlDataClassification DataSourceKind = "SqlDataClassification" + DataSourceKindWindowsEvent DataSourceKind = "WindowsEvent" + DataSourceKindWindowsPerformanceCounter DataSourceKind = "WindowsPerformanceCounter" + DataSourceKindWindowsTelemetry DataSourceKind = "WindowsTelemetry" +) + +func PossibleValuesForDataSourceKind() []string { + return []string{ + string(DataSourceKindApplicationInsights), + string(DataSourceKindAzureActivityLog), + string(DataSourceKindAzureAuditLog), + string(DataSourceKindChangeTrackingContentLocation), + string(DataSourceKindChangeTrackingCustomPath), + string(DataSourceKindChangeTrackingDataTypeConfiguration), + string(DataSourceKindChangeTrackingDefaultRegistry), + string(DataSourceKindChangeTrackingLinuxPath), + string(DataSourceKindChangeTrackingPath), + string(DataSourceKindChangeTrackingRegistry), + string(DataSourceKindChangeTrackingServices), + string(DataSourceKindCustomLog), + string(DataSourceKindCustomLogCollection), + string(DataSourceKindDnsAnalytics), + string(DataSourceKindGenericDataSource), + string(DataSourceKindIISLogs), + string(DataSourceKindImportComputerGroup), + string(DataSourceKindItsm), + string(DataSourceKindLinuxChangeTrackingPath), + string(DataSourceKindLinuxPerformanceCollection), + string(DataSourceKindLinuxPerformanceObject), + string(DataSourceKindLinuxSyslog), + string(DataSourceKindLinuxSyslogCollection), + string(DataSourceKindNetworkMonitoring), + string(DataSourceKindOfficeThreeSixFive), + string(DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration), + string(DataSourceKindSecurityEventCollectionConfiguration), + string(DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration), + string(DataSourceKindSecurityWindowsBaselineConfiguration), + string(DataSourceKindSqlDataClassification), + string(DataSourceKindWindowsEvent), + string(DataSourceKindWindowsPerformanceCounter), + string(DataSourceKindWindowsTelemetry), + } +} + +func (s *DataSourceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSourceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSourceKind(input string) (*DataSourceKind, error) { + vals := map[string]DataSourceKind{ + "applicationinsights": DataSourceKindApplicationInsights, + "azureactivitylog": DataSourceKindAzureActivityLog, + "azureauditlog": DataSourceKindAzureAuditLog, + "changetrackingcontentlocation": DataSourceKindChangeTrackingContentLocation, + "changetrackingcustompath": DataSourceKindChangeTrackingCustomPath, + "changetrackingdatatypeconfiguration": DataSourceKindChangeTrackingDataTypeConfiguration, + "changetrackingdefaultregistry": DataSourceKindChangeTrackingDefaultRegistry, + "changetrackinglinuxpath": DataSourceKindChangeTrackingLinuxPath, + "changetrackingpath": DataSourceKindChangeTrackingPath, + "changetrackingregistry": DataSourceKindChangeTrackingRegistry, + "changetrackingservices": DataSourceKindChangeTrackingServices, + "customlog": DataSourceKindCustomLog, + "customlogcollection": DataSourceKindCustomLogCollection, + "dnsanalytics": DataSourceKindDnsAnalytics, + "genericdatasource": DataSourceKindGenericDataSource, + "iislogs": DataSourceKindIISLogs, + "importcomputergroup": DataSourceKindImportComputerGroup, + "itsm": DataSourceKindItsm, + "linuxchangetrackingpath": DataSourceKindLinuxChangeTrackingPath, + "linuxperformancecollection": DataSourceKindLinuxPerformanceCollection, + "linuxperformanceobject": DataSourceKindLinuxPerformanceObject, + "linuxsyslog": DataSourceKindLinuxSyslog, + "linuxsyslogcollection": DataSourceKindLinuxSyslogCollection, + "networkmonitoring": DataSourceKindNetworkMonitoring, + "office365": DataSourceKindOfficeThreeSixFive, + "securitycentersecuritywindowsbaselineconfiguration": DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration, + "securityeventcollectionconfiguration": DataSourceKindSecurityEventCollectionConfiguration, + "securityinsightssecurityeventcollectionconfiguration": DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration, + "securitywindowsbaselineconfiguration": DataSourceKindSecurityWindowsBaselineConfiguration, + "sqldataclassification": DataSourceKindSqlDataClassification, + "windowsevent": DataSourceKindWindowsEvent, + "windowsperformancecounter": DataSourceKindWindowsPerformanceCounter, + "windowstelemetry": DataSourceKindWindowsTelemetry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceKind(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go new file mode 100644 index 00000000000..2a95ddb8e6c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go @@ -0,0 +1,139 @@ +package datasources + +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(&DataSourceId{}) +} + +var _ resourceids.ResourceId = &DataSourceId{} + +// DataSourceId is a struct representing the Resource ID for a Data Source +type DataSourceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataSourceName string +} + +// NewDataSourceID returns a new DataSourceId struct +func NewDataSourceID(subscriptionId string, resourceGroupName string, workspaceName string, dataSourceName string) DataSourceId { + return DataSourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataSourceName: dataSourceName, + } +} + +// ParseDataSourceID parses 'input' into a DataSourceId +func ParseDataSourceID(input string) (*DataSourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataSourceIDInsensitively parses 'input' case-insensitively into a DataSourceId +// note: this method should only be used for API response data and not user input +func ParseDataSourceIDInsensitively(input string) (*DataSourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataSourceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataSourceName, ok = input.Parsed["dataSourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataSourceName", input) + } + + return nil +} + +// ValidateDataSourceID checks that 'input' can be parsed as a Data Source ID +func ValidateDataSourceID(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 := ParseDataSourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Source ID +func (id DataSourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataSources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataSourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Source ID +func (id DataSourceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticDataSources", "dataSources", "dataSources"), + resourceids.UserSpecifiedSegment("dataSourceName", "dataSourceName"), + } +} + +// String returns a human-readable description of this Data Source ID +func (id DataSourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Source Name: %q", id.DataSourceName), + } + return fmt.Sprintf("Data Source (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go new file mode 100644 index 00000000000..13a6a7a7e0c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go @@ -0,0 +1,327 @@ +package datasources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataSourceId{} + +func TestNewDataSourceID(t *testing.T) { + id := NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataSourceName != "dataSourceName" { + t.Fatalf("Expected %q but got %q for Segment 'DataSourceName'", id.DataSourceName, "dataSourceName") + } +} + +func TestFormatDataSourceID(t *testing.T) { + actual := NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataSourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceName: "dataSourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceName != v.Expected.DataSourceName { + t.Fatalf("Expected %q but got %q for DataSourceName", v.Expected.DataSourceName, actual.DataSourceName) + } + + } +} + +func TestParseDataSourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceName: "dataSourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs/dAtAsOuRcEnAmE", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataSourceName: "dAtAsOuRcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs/dAtAsOuRcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceName != v.Expected.DataSourceName { + t.Fatalf("Expected %q but got %q for DataSourceName", v.Expected.DataSourceName, actual.DataSourceName) + } + + } +} + +func TestSegmentsForDataSourceId(t *testing.T) { + segments := DataSourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataSourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go new file mode 100644 index 00000000000..5325c571db5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go @@ -0,0 +1,130 @@ +package datasources + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go new file mode 100644 index 00000000000..a4e30459ef1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go @@ -0,0 +1,282 @@ +package datasources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go new file mode 100644 index 00000000000..0f409fcbaab --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go @@ -0,0 +1,58 @@ +package datasources + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataSource +} + +// CreateOrUpdate ... +func (c DataSourcesClient) CreateOrUpdate(ctx context.Context, id DataSourceId, input DataSource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DataSource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go new file mode 100644 index 00000000000..e997877cfd3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go @@ -0,0 +1,47 @@ +package datasources + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DataSourcesClient) Delete(ctx context.Context, id DataSourceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go new file mode 100644 index 00000000000..388310f131e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go @@ -0,0 +1,53 @@ +package datasources + +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 *DataSource +} + +// Get ... +func (c DataSourcesClient) Get(ctx context.Context, id DataSourceId) (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 DataSource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go new file mode 100644 index 00000000000..909910b2332 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go @@ -0,0 +1,134 @@ +package datasources + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataSource +} + +type ListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataSource +} + +type ListByWorkspaceOperationOptions struct { + Filter *string +} + +func DefaultListByWorkspaceOperationOptions() ListByWorkspaceOperationOptions { + return ListByWorkspaceOperationOptions{} +} + +func (o ListByWorkspaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByWorkspaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByWorkspaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByWorkspace ... +func (c DataSourcesClient) ListByWorkspace(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByWorkspaceCustomPager{}, + Path: fmt.Sprintf("%s/dataSources", 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 *[]DataSource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByWorkspaceComplete retrieves all the results into a single object +func (c DataSourcesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, options, DataSourceOperationPredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataSourcesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions, predicate DataSourceOperationPredicate) (result ListByWorkspaceCompleteResult, err error) { + items := make([]DataSource, 0) + + resp, err := c.ListByWorkspace(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 = ListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go b/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go new file mode 100644 index 00000000000..e091f526268 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go @@ -0,0 +1,14 @@ +package datasources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind DataSourceKind `json:"kind"` + Name *string `json:"name,omitempty"` + Properties interface{} `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go b/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go new file mode 100644 index 00000000000..1fa7b8ec8d5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go @@ -0,0 +1,37 @@ +package datasources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSourceOperationPredicate struct { + Etag *string + Id *string + Name *string + Properties *interface{} + Type *string +} + +func (p DataSourceOperationPredicate) Matches(input DataSource) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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.Properties != nil && *p.Properties != input.Properties { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/version.go b/resource-manager/operationalinsights/2023-09-01/datasources/version.go new file mode 100644 index 00000000000..c840691a378 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/version.go @@ -0,0 +1,10 @@ +package datasources + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datasources/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md new file mode 100644 index 00000000000..7cf1c62469a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md @@ -0,0 +1,68 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/intelligencepacks` Documentation + +The `intelligencepacks` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/intelligencepacks" +``` + + +### Client Initialization + +```go +client := intelligencepacks.NewIntelligencePacksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `IntelligencePacksClient.Disable` + +```go +ctx := context.TODO() +id := intelligencepacks.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.Disable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IntelligencePacksClient.Enable` + +```go +ctx := context.TODO() +id := intelligencepacks.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.Enable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IntelligencePacksClient.List` + +```go +ctx := context.TODO() +id := intelligencepacks.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go new file mode 100644 index 00000000000..518c60eaae5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go @@ -0,0 +1,26 @@ +package intelligencepacks + +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 IntelligencePacksClient struct { + Client *resourcemanager.Client +} + +func NewIntelligencePacksClientWithBaseURI(sdkApi sdkEnv.Api) (*IntelligencePacksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "intelligencepacks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IntelligencePacksClient: %+v", err) + } + + return &IntelligencePacksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go new file mode 100644 index 00000000000..ee98a42386d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go @@ -0,0 +1,139 @@ +package intelligencepacks + +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(&IntelligencePackId{}) +} + +var _ resourceids.ResourceId = &IntelligencePackId{} + +// IntelligencePackId is a struct representing the Resource ID for a Intelligence Pack +type IntelligencePackId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IntelligencePackName string +} + +// NewIntelligencePackID returns a new IntelligencePackId struct +func NewIntelligencePackID(subscriptionId string, resourceGroupName string, workspaceName string, intelligencePackName string) IntelligencePackId { + return IntelligencePackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IntelligencePackName: intelligencePackName, + } +} + +// ParseIntelligencePackID parses 'input' into a IntelligencePackId +func ParseIntelligencePackID(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIntelligencePackIDInsensitively parses 'input' case-insensitively into a IntelligencePackId +// note: this method should only be used for API response data and not user input +func ParseIntelligencePackIDInsensitively(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IntelligencePackId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.IntelligencePackName, ok = input.Parsed["intelligencePackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "intelligencePackName", input) + } + + return nil +} + +// ValidateIntelligencePackID checks that 'input' can be parsed as a Intelligence Pack ID +func ValidateIntelligencePackID(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 := ParseIntelligencePackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Intelligence Pack ID +func (id IntelligencePackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/intelligencePacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IntelligencePackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Intelligence Pack ID +func (id IntelligencePackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticIntelligencePacks", "intelligencePacks", "intelligencePacks"), + resourceids.UserSpecifiedSegment("intelligencePackName", "intelligencePackName"), + } +} + +// String returns a human-readable description of this Intelligence Pack ID +func (id IntelligencePackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Intelligence Pack Name: %q", id.IntelligencePackName), + } + return fmt.Sprintf("Intelligence Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go new file mode 100644 index 00000000000..032f02668b8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go @@ -0,0 +1,327 @@ +package intelligencepacks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IntelligencePackId{} + +func TestNewIntelligencePackID(t *testing.T) { + id := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.IntelligencePackName != "intelligencePackName" { + t.Fatalf("Expected %q but got %q for Segment 'IntelligencePackName'", id.IntelligencePackName, "intelligencePackName") + } +} + +func TestFormatIntelligencePackID(t *testing.T) { + actual := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIntelligencePackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestParseIntelligencePackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + IntelligencePackName: "iNtElLiGeNcEpAcKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestSegmentsForIntelligencePackId(t *testing.T) { + segments := IntelligencePackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IntelligencePackId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go new file mode 100644 index 00000000000..f771f3365e1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go @@ -0,0 +1,130 @@ +package intelligencepacks + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go new file mode 100644 index 00000000000..d5445b09646 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go @@ -0,0 +1,282 @@ +package intelligencepacks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go new file mode 100644 index 00000000000..1697c5db1e6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go @@ -0,0 +1,47 @@ +package intelligencepacks + +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 DisableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Disable ... +func (c IntelligencePacksClient) Disable(ctx context.Context, id IntelligencePackId) (result DisableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go new file mode 100644 index 00000000000..cdae66e4a20 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go @@ -0,0 +1,47 @@ +package intelligencepacks + +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 EnableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Enable ... +func (c IntelligencePacksClient) Enable(ctx context.Context, id IntelligencePackId) (result EnableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enable", 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/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go new file mode 100644 index 00000000000..935b628393d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go @@ -0,0 +1,54 @@ +package intelligencepacks + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IntelligencePack +} + +// List ... +func (c IntelligencePacksClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/intelligencePacks", 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 []IntelligencePack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go new file mode 100644 index 00000000000..258fdc2abbf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go @@ -0,0 +1,10 @@ +package intelligencepacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IntelligencePack struct { + DisplayName *string `json:"displayName,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go new file mode 100644 index 00000000000..0b39d9ca4e1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go @@ -0,0 +1,10 @@ +package intelligencepacks + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/intelligencepacks/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md b/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md new file mode 100644 index 00000000000..1d6f2cc32db --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md @@ -0,0 +1,81 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedservices` Documentation + +The `linkedservices` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedservices" +``` + + +### Client Initialization + +```go +client := linkedservices.NewLinkedServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LinkedServicesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +payload := linkedservices.LinkedService{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LinkedServicesClient.Delete` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LinkedServicesClient.Get` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +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: `LinkedServicesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := linkedservices.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go new file mode 100644 index 00000000000..3dad68f5d5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go @@ -0,0 +1,26 @@ +package linkedservices + +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 LinkedServicesClient struct { + Client *resourcemanager.Client +} + +func NewLinkedServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*LinkedServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "linkedservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LinkedServicesClient: %+v", err) + } + + return &LinkedServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go new file mode 100644 index 00000000000..8522d1f6ced --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go @@ -0,0 +1,57 @@ +package linkedservices + +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 LinkedServiceEntityStatus string + +const ( + LinkedServiceEntityStatusDeleting LinkedServiceEntityStatus = "Deleting" + LinkedServiceEntityStatusProvisioningAccount LinkedServiceEntityStatus = "ProvisioningAccount" + LinkedServiceEntityStatusSucceeded LinkedServiceEntityStatus = "Succeeded" + LinkedServiceEntityStatusUpdating LinkedServiceEntityStatus = "Updating" +) + +func PossibleValuesForLinkedServiceEntityStatus() []string { + return []string{ + string(LinkedServiceEntityStatusDeleting), + string(LinkedServiceEntityStatusProvisioningAccount), + string(LinkedServiceEntityStatusSucceeded), + string(LinkedServiceEntityStatusUpdating), + } +} + +func (s *LinkedServiceEntityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinkedServiceEntityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinkedServiceEntityStatus(input string) (*LinkedServiceEntityStatus, error) { + vals := map[string]LinkedServiceEntityStatus{ + "deleting": LinkedServiceEntityStatusDeleting, + "provisioningaccount": LinkedServiceEntityStatusProvisioningAccount, + "succeeded": LinkedServiceEntityStatusSucceeded, + "updating": LinkedServiceEntityStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinkedServiceEntityStatus(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go new file mode 100644 index 00000000000..a2f3b24e491 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go @@ -0,0 +1,139 @@ +package linkedservices + +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(&LinkedServiceId{}) +} + +var _ resourceids.ResourceId = &LinkedServiceId{} + +// LinkedServiceId is a struct representing the Resource ID for a Linked Service +type LinkedServiceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + LinkedServiceName string +} + +// NewLinkedServiceID returns a new LinkedServiceId struct +func NewLinkedServiceID(subscriptionId string, resourceGroupName string, workspaceName string, linkedServiceName string) LinkedServiceId { + return LinkedServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + LinkedServiceName: linkedServiceName, + } +} + +// ParseLinkedServiceID parses 'input' into a LinkedServiceId +func ParseLinkedServiceID(input string) (*LinkedServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkedServiceIDInsensitively parses 'input' case-insensitively into a LinkedServiceId +// note: this method should only be used for API response data and not user input +func ParseLinkedServiceIDInsensitively(input string) (*LinkedServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkedServiceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.LinkedServiceName, ok = input.Parsed["linkedServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedServiceName", input) + } + + return nil +} + +// ValidateLinkedServiceID checks that 'input' can be parsed as a Linked Service ID +func ValidateLinkedServiceID(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 := ParseLinkedServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Linked Service ID +func (id LinkedServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.LinkedServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Linked Service ID +func (id LinkedServiceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticLinkedServices", "linkedServices", "linkedServices"), + resourceids.UserSpecifiedSegment("linkedServiceName", "linkedServiceName"), + } +} + +// String returns a human-readable description of this Linked Service ID +func (id LinkedServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Linked Service Name: %q", id.LinkedServiceName), + } + return fmt.Sprintf("Linked Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go new file mode 100644 index 00000000000..93e06914e53 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go @@ -0,0 +1,327 @@ +package linkedservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LinkedServiceId{} + +func TestNewLinkedServiceID(t *testing.T) { + id := NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.LinkedServiceName != "linkedServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedServiceName'", id.LinkedServiceName, "linkedServiceName") + } +} + +func TestFormatLinkedServiceID(t *testing.T) { + actual := NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkedServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + LinkedServiceName: "linkedServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.LinkedServiceName != v.Expected.LinkedServiceName { + t.Fatalf("Expected %q but got %q for LinkedServiceName", v.Expected.LinkedServiceName, actual.LinkedServiceName) + } + + } +} + +func TestParseLinkedServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + LinkedServiceName: "linkedServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS/lInKeDsErViCeNaMe", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + LinkedServiceName: "lInKeDsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS/lInKeDsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.LinkedServiceName != v.Expected.LinkedServiceName { + t.Fatalf("Expected %q but got %q for LinkedServiceName", v.Expected.LinkedServiceName, actual.LinkedServiceName) + } + + } +} + +func TestSegmentsForLinkedServiceId(t *testing.T) { + segments := LinkedServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkedServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go new file mode 100644 index 00000000000..16b754510d2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go @@ -0,0 +1,130 @@ +package linkedservices + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go new file mode 100644 index 00000000000..7df7975ebf9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go @@ -0,0 +1,282 @@ +package linkedservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go new file mode 100644 index 00000000000..18c4e4d1dd4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go @@ -0,0 +1,76 @@ +package linkedservices + +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 *LinkedService +} + +// CreateOrUpdate ... +func (c LinkedServicesClient) CreateOrUpdate(ctx context.Context, id LinkedServiceId, input LinkedService) (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 LinkedServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id LinkedServiceId, input LinkedService) 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/resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go new file mode 100644 index 00000000000..65d01a5e7aa --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go @@ -0,0 +1,72 @@ +package linkedservices + +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 + Model *LinkedService +} + +// Delete ... +func (c LinkedServicesClient) Delete(ctx context.Context, id LinkedServiceId) (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 LinkedServicesClient) DeleteThenPoll(ctx context.Context, id LinkedServiceId) 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/resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go new file mode 100644 index 00000000000..f4d0d98ffdd --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go @@ -0,0 +1,53 @@ +package linkedservices + +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 *LinkedService +} + +// Get ... +func (c LinkedServicesClient) Get(ctx context.Context, id LinkedServiceId) (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 LinkedService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go new file mode 100644 index 00000000000..9c72f2b544d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package linkedservices + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedServiceListResult +} + +// ListByWorkspace ... +func (c LinkedServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedServices", 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 LinkedServiceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go new file mode 100644 index 00000000000..f4b120ae7af --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go @@ -0,0 +1,12 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedService struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties LinkedServiceProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go new file mode 100644 index 00000000000..8d5731b5785 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go @@ -0,0 +1,8 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedServiceListResult struct { + Value *[]LinkedService `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go new file mode 100644 index 00000000000..779209d9e11 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go @@ -0,0 +1,10 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedServiceProperties struct { + ProvisioningState *LinkedServiceEntityStatus `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WriteAccessResourceId *string `json:"writeAccessResourceId,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go new file mode 100644 index 00000000000..9d1b1401113 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go @@ -0,0 +1,10 @@ +package linkedservices + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/linkedservices/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md new file mode 100644 index 00000000000..ebd03e52619 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts` Documentation + +The `linkedstorageaccounts` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts" +``` + + +### Client Initialization + +```go +client := linkedstorageaccounts.NewLinkedStorageAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LinkedStorageAccountsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +payload := linkedstorageaccounts.LinkedStorageAccountsResource{ + // ... +} + + +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: `LinkedStorageAccountsClient.Delete` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +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: `LinkedStorageAccountsClient.Get` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +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: `LinkedStorageAccountsClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go new file mode 100644 index 00000000000..951ac7536f6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go @@ -0,0 +1,26 @@ +package linkedstorageaccounts + +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 LinkedStorageAccountsClient struct { + Client *resourcemanager.Client +} + +func NewLinkedStorageAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*LinkedStorageAccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "linkedstorageaccounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LinkedStorageAccountsClient: %+v", err) + } + + return &LinkedStorageAccountsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go new file mode 100644 index 00000000000..abf0284b4b7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go @@ -0,0 +1,60 @@ +package linkedstorageaccounts + +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 DataSourceType string + +const ( + DataSourceTypeAlerts DataSourceType = "Alerts" + DataSourceTypeAzureWatson DataSourceType = "AzureWatson" + DataSourceTypeCustomLogs DataSourceType = "CustomLogs" + DataSourceTypeIngestion DataSourceType = "Ingestion" + DataSourceTypeQuery DataSourceType = "Query" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAlerts), + string(DataSourceTypeAzureWatson), + string(DataSourceTypeCustomLogs), + string(DataSourceTypeIngestion), + string(DataSourceTypeQuery), + } +} + +func (s *DataSourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "alerts": DataSourceTypeAlerts, + "azurewatson": DataSourceTypeAzureWatson, + "customlogs": DataSourceTypeCustomLogs, + "ingestion": DataSourceTypeIngestion, + "query": DataSourceTypeQuery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go new file mode 100644 index 00000000000..42d6a1c2a50 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go @@ -0,0 +1,147 @@ +package linkedstorageaccounts + +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(&DataSourceTypeId{}) +} + +var _ resourceids.ResourceId = &DataSourceTypeId{} + +// DataSourceTypeId is a struct representing the Resource ID for a Data Source Type +type DataSourceTypeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataSourceType DataSourceType +} + +// NewDataSourceTypeID returns a new DataSourceTypeId struct +func NewDataSourceTypeID(subscriptionId string, resourceGroupName string, workspaceName string, dataSourceType DataSourceType) DataSourceTypeId { + return DataSourceTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataSourceType: dataSourceType, + } +} + +// ParseDataSourceTypeID parses 'input' into a DataSourceTypeId +func ParseDataSourceTypeID(input string) (*DataSourceTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceTypeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataSourceTypeIDInsensitively parses 'input' case-insensitively into a DataSourceTypeId +// note: this method should only be used for API response data and not user input +func ParseDataSourceTypeIDInsensitively(input string) (*DataSourceTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceTypeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataSourceTypeId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if v, ok := input.Parsed["dataSourceType"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataSourceType", input) + } + + dataSourceType, err := parseDataSourceType(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.DataSourceType = *dataSourceType + } + + return nil +} + +// ValidateDataSourceTypeID checks that 'input' can be parsed as a Data Source Type ID +func ValidateDataSourceTypeID(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 := ParseDataSourceTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Source Type ID +func (id DataSourceTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedStorageAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, string(id.DataSourceType)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Source Type ID +func (id DataSourceTypeId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticLinkedStorageAccounts", "linkedStorageAccounts", "linkedStorageAccounts"), + resourceids.ConstantSegment("dataSourceType", PossibleValuesForDataSourceType(), "Alerts"), + } +} + +// String returns a human-readable description of this Data Source Type ID +func (id DataSourceTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Source Type: %q", string(id.DataSourceType)), + } + return fmt.Sprintf("Data Source Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go new file mode 100644 index 00000000000..dd022522a17 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go @@ -0,0 +1,327 @@ +package linkedstorageaccounts + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataSourceTypeId{} + +func TestNewDataSourceTypeID(t *testing.T) { + id := NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataSourceType != "Alerts" { + t.Fatalf("Expected %q but got %q for Segment 'DataSourceType'", id.DataSourceType, "Alerts") + } +} + +func TestFormatDataSourceTypeID(t *testing.T) { + actual := NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataSourceTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceTypeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceType: "Alerts", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceTypeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceType != v.Expected.DataSourceType { + t.Fatalf("Expected %q but got %q for DataSourceType", v.Expected.DataSourceType, actual.DataSourceType) + } + + } +} + +func TestParseDataSourceTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceTypeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceType: "Alerts", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs/aLeRtS", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataSourceType: "Alerts", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs/aLeRtS/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceTypeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceType != v.Expected.DataSourceType { + t.Fatalf("Expected %q but got %q for DataSourceType", v.Expected.DataSourceType, actual.DataSourceType) + } + + } +} + +func TestSegmentsForDataSourceTypeId(t *testing.T) { + segments := DataSourceTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataSourceTypeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go new file mode 100644 index 00000000000..1f6d261f8a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go @@ -0,0 +1,130 @@ +package linkedstorageaccounts + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go new file mode 100644 index 00000000000..9e32eb5abee --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go @@ -0,0 +1,282 @@ +package linkedstorageaccounts + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go new file mode 100644 index 00000000000..713373c104f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go @@ -0,0 +1,57 @@ +package linkedstorageaccounts + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedStorageAccountsResource +} + +// CreateOrUpdate ... +func (c LinkedStorageAccountsClient) CreateOrUpdate(ctx context.Context, id DataSourceTypeId, input LinkedStorageAccountsResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LinkedStorageAccountsResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go new file mode 100644 index 00000000000..65907ea3542 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go @@ -0,0 +1,46 @@ +package linkedstorageaccounts + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c LinkedStorageAccountsClient) Delete(ctx context.Context, id DataSourceTypeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go new file mode 100644 index 00000000000..085a74b9f9a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go @@ -0,0 +1,53 @@ +package linkedstorageaccounts + +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 *LinkedStorageAccountsResource +} + +// Get ... +func (c LinkedStorageAccountsClient) Get(ctx context.Context, id DataSourceTypeId) (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 LinkedStorageAccountsResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go new file mode 100644 index 00000000000..2e40bd1dc6c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package linkedstorageaccounts + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedStorageAccountsListResult +} + +// ListByWorkspace ... +func (c LinkedStorageAccountsClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedStorageAccounts", 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 LinkedStorageAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go new file mode 100644 index 00000000000..d9be9e74ab9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go @@ -0,0 +1,8 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsListResult struct { + Value *[]LinkedStorageAccountsResource `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go new file mode 100644 index 00000000000..43730125135 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go @@ -0,0 +1,9 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsProperties struct { + DataSourceType *DataSourceType `json:"dataSourceType,omitempty"` + StorageAccountIds *[]string `json:"storageAccountIds,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go new file mode 100644 index 00000000000..c4a02711ff6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go @@ -0,0 +1,11 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties LinkedStorageAccountsProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go new file mode 100644 index 00000000000..a3453f2616e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go @@ -0,0 +1,10 @@ +package linkedstorageaccounts + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/linkedstorageaccounts/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md b/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md new file mode 100644 index 00000000000..01cb5541ce6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypackqueries` Documentation + +The `querypackqueries` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypackqueries" +``` + + +### Client Initialization + +```go +client := querypackqueries.NewQueryPackQueriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesDelete` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +read, err := client.QueriesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesGet` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +read, err := client.QueriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesList` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +// alternatively `client.QueriesList(ctx, id, querypackqueries.DefaultQueriesListOperationOptions())` can be used to do batched pagination +items, err := client.QueriesListComplete(ctx, id, querypackqueries.DefaultQueriesListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesPut` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +payload := querypackqueries.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesPut(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesSearch` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypackqueries.LogAnalyticsQueryPackQuerySearchProperties{ + // ... +} + + +// alternatively `client.QueriesSearch(ctx, id, payload, querypackqueries.DefaultQueriesSearchOperationOptions())` can be used to do batched pagination +items, err := client.QueriesSearchComplete(ctx, id, payload, querypackqueries.DefaultQueriesSearchOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesUpdate` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +payload := querypackqueries.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go new file mode 100644 index 00000000000..d858936012f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go @@ -0,0 +1,26 @@ +package querypackqueries + +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 QueryPackQueriesClient struct { + Client *resourcemanager.Client +} + +func NewQueryPackQueriesClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryPackQueriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querypackqueries", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryPackQueriesClient: %+v", err) + } + + return &QueryPackQueriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go new file mode 100644 index 00000000000..d28ec182a6d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go @@ -0,0 +1,139 @@ +package querypackqueries + +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(&QueryId{}) +} + +var _ resourceids.ResourceId = &QueryId{} + +// QueryId is a struct representing the Resource ID for a Query +type QueryId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string + QueryName string +} + +// NewQueryID returns a new QueryId struct +func NewQueryID(subscriptionId string, resourceGroupName string, queryPackName string, queryName string) QueryId { + return QueryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + QueryName: queryName, + } +} + +// ParseQueryID parses 'input' into a QueryId +func ParseQueryID(input string) (*QueryId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryIDInsensitively parses 'input' case-insensitively into a QueryId +// note: this method should only be used for API response data and not user input +func ParseQueryIDInsensitively(input string) (*QueryId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + if id.QueryName, ok = input.Parsed["queryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryName", input) + } + + return nil +} + +// ValidateQueryID checks that 'input' can be parsed as a Query ID +func ValidateQueryID(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 := ParseQueryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query ID +func (id QueryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s/queries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName, id.QueryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query ID +func (id QueryId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + resourceids.StaticSegment("staticQueries", "queries", "queries"), + resourceids.UserSpecifiedSegment("queryName", "queryName"), + } +} + +// String returns a human-readable description of this Query ID +func (id QueryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + fmt.Sprintf("Query Name: %q", id.QueryName), + } + return fmt.Sprintf("Query (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go new file mode 100644 index 00000000000..41156889895 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go @@ -0,0 +1,327 @@ +package querypackqueries + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &QueryId{} + +func TestNewQueryID(t *testing.T) { + id := NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } + + if id.QueryName != "queryName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryName'", id.QueryName, "queryName") + } +} + +func TestFormatQueryID(t *testing.T) { + actual := NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + QueryName: "queryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + if actual.QueryName != v.Expected.QueryName { + t.Fatalf("Expected %q but got %q for QueryName", v.Expected.QueryName, actual.QueryName) + } + + } +} + +func TestParseQueryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + QueryName: "queryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs/qUeRyNaMe", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + QueryName: "qUeRyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs/qUeRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + if actual.QueryName != v.Expected.QueryName { + t.Fatalf("Expected %q but got %q for QueryName", v.Expected.QueryName, actual.QueryName) + } + + } +} + +func TestSegmentsForQueryId(t *testing.T) { + segments := QueryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go new file mode 100644 index 00000000000..4f2002aa009 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go @@ -0,0 +1,130 @@ +package querypackqueries + +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(&QueryPackId{}) +} + +var _ resourceids.ResourceId = &QueryPackId{} + +// QueryPackId is a struct representing the Resource ID for a Query Pack +type QueryPackId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string +} + +// NewQueryPackID returns a new QueryPackId struct +func NewQueryPackID(subscriptionId string, resourceGroupName string, queryPackName string) QueryPackId { + return QueryPackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + } +} + +// ParseQueryPackID parses 'input' into a QueryPackId +func ParseQueryPackID(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryPackIDInsensitively parses 'input' case-insensitively into a QueryPackId +// note: this method should only be used for API response data and not user input +func ParseQueryPackIDInsensitively(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryPackId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + return nil +} + +// ValidateQueryPackID checks that 'input' can be parsed as a Query Pack ID +func ValidateQueryPackID(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 := ParseQueryPackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query Pack ID +func (id QueryPackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query Pack ID +func (id QueryPackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + } +} + +// String returns a human-readable description of this Query Pack ID +func (id QueryPackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + } + return fmt.Sprintf("Query Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go new file mode 100644 index 00000000000..eef7759ac06 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go @@ -0,0 +1,282 @@ +package querypackqueries + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &QueryPackId{} + +func TestNewQueryPackID(t *testing.T) { + id := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } +} + +func TestFormatQueryPackID(t *testing.T) { + actual := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryPackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestParseQueryPackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestSegmentsForQueryPackId(t *testing.T) { + segments := QueryPackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryPackId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go new file mode 100644 index 00000000000..39ddfb9e4d7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go @@ -0,0 +1,47 @@ +package querypackqueries + +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 QueriesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// QueriesDelete ... +func (c QueryPackQueriesClient) QueriesDelete(ctx context.Context, id QueryId) (result QueriesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go new file mode 100644 index 00000000000..ff8ffe93a7a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go @@ -0,0 +1,53 @@ +package querypackqueries + +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 QueriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesGet ... +func (c QueryPackQueriesClient) QueriesGet(ctx context.Context, id QueryId) (result QueriesGetOperationResponse, 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 LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go new file mode 100644 index 00000000000..f6173d9275c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go @@ -0,0 +1,138 @@ +package querypackqueries + +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 QueriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogAnalyticsQueryPackQuery +} + +type QueriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPackQuery +} + +type QueriesListOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesListOperationOptions() QueriesListOperationOptions { + return QueriesListOperationOptions{} +} + +func (o QueriesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o QueriesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o QueriesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeBody != nil { + out.Append("includeBody", fmt.Sprintf("%v", *o.IncludeBody)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type QueriesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *QueriesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// QueriesList ... +func (c QueryPackQueriesClient) QueriesList(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (result QueriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &QueriesListCustomPager{}, + Path: fmt.Sprintf("%s/queries", 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 *[]LogAnalyticsQueryPackQuery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// QueriesListComplete retrieves all the results into a single object +func (c QueryPackQueriesClient) QueriesListComplete(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (QueriesListCompleteResult, error) { + return c.QueriesListCompleteMatchingPredicate(ctx, id, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPackQueriesClient) QueriesListCompleteMatchingPredicate(ctx context.Context, id QueryPackId, options QueriesListOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (result QueriesListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + resp, err := c.QueriesList(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 = QueriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go new file mode 100644 index 00000000000..ecf150a8195 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go @@ -0,0 +1,57 @@ +package querypackqueries + +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 QueriesPutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesPut ... +func (c QueryPackQueriesClient) QueriesPut(ctx context.Context, id QueryId, input LogAnalyticsQueryPackQuery) (result QueriesPutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go new file mode 100644 index 00000000000..7342fa8eeec --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go @@ -0,0 +1,138 @@ +package querypackqueries + +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 QueriesSearchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogAnalyticsQueryPackQuery +} + +type QueriesSearchCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPackQuery +} + +type QueriesSearchOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesSearchOperationOptions() QueriesSearchOperationOptions { + return QueriesSearchOperationOptions{} +} + +func (o QueriesSearchOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o QueriesSearchOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o QueriesSearchOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeBody != nil { + out.Append("includeBody", fmt.Sprintf("%v", *o.IncludeBody)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type QueriesSearchCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *QueriesSearchCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// QueriesSearch ... +func (c QueryPackQueriesClient) QueriesSearch(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (result QueriesSearchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &QueriesSearchCustomPager{}, + Path: fmt.Sprintf("%s/queries/search", 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 *[]LogAnalyticsQueryPackQuery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// QueriesSearchComplete retrieves all the results into a single object +func (c QueryPackQueriesClient) QueriesSearchComplete(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (QueriesSearchCompleteResult, error) { + return c.QueriesSearchCompleteMatchingPredicate(ctx, id, input, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesSearchCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPackQueriesClient) QueriesSearchCompleteMatchingPredicate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (result QueriesSearchCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + resp, err := c.QueriesSearch(ctx, id, input, 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 = QueriesSearchCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go new file mode 100644 index 00000000000..8a547b353c8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go @@ -0,0 +1,57 @@ +package querypackqueries + +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 QueriesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesUpdate ... +func (c QueryPackQueriesClient) QueriesUpdate(ctx context.Context, id QueryId, input LogAnalyticsQueryPackQuery) (result QueriesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go new file mode 100644 index 00000000000..555d2bf023c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go @@ -0,0 +1,16 @@ +package querypackqueries + +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 LogAnalyticsQueryPackQuery struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogAnalyticsQueryPackQueryProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go new file mode 100644 index 00000000000..25dc4ae2a31 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go @@ -0,0 +1,47 @@ +package querypackqueries + +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 LogAnalyticsQueryPackQueryProperties struct { + Author *string `json:"author,omitempty"` + Body string `json:"body"` + Description *string `json:"description,omitempty"` + DisplayName string `json:"displayName"` + Id *string `json:"id,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + Related *LogAnalyticsQueryPackQueryPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go new file mode 100644 index 00000000000..5efd7bd3027 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go @@ -0,0 +1,10 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go new file mode 100644 index 00000000000..5845c3f78ce --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go @@ -0,0 +1,9 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchProperties struct { + Related *LogAnalyticsQueryPackQuerySearchPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go new file mode 100644 index 00000000000..d2c6bc8c290 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go @@ -0,0 +1,10 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go new file mode 100644 index 00000000000..38fda83f51a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go @@ -0,0 +1,27 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackQueryOperationPredicate) Matches(input LogAnalyticsQueryPackQuery) 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/resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go new file mode 100644 index 00000000000..7a6c807d036 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go @@ -0,0 +1,10 @@ +package querypackqueries + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querypackqueries/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/README.md b/resource-manager/operationalinsights/2023-09-01/querypacks/README.md new file mode 100644 index 00000000000..e320d71f521 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/README.md @@ -0,0 +1,150 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks` Documentation + +The `querypacks` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks" +``` + + +### Client Initialization + +```go +client := querypacks.NewQueryPacksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryPacksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypacks.LogAnalyticsQueryPack{ + // ... +} + + +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: `QueryPacksClient.CreateOrUpdateWithoutName` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := querypacks.LogAnalyticsQueryPack{ + // ... +} + + +read, err := client.CreateOrUpdateWithoutName(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPacksClient.Delete` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +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: `QueryPacksClient.Get` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +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: `QueryPacksClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPacksClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPacksClient.UpdateTags` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypacks.TagsResource{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/client.go b/resource-manager/operationalinsights/2023-09-01/querypacks/client.go new file mode 100644 index 00000000000..5efc5278ddd --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/client.go @@ -0,0 +1,26 @@ +package querypacks + +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 QueryPacksClient struct { + Client *resourcemanager.Client +} + +func NewQueryPacksClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryPacksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querypacks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryPacksClient: %+v", err) + } + + return &QueryPacksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go new file mode 100644 index 00000000000..3fe4cc2c22f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go @@ -0,0 +1,130 @@ +package querypacks + +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(&QueryPackId{}) +} + +var _ resourceids.ResourceId = &QueryPackId{} + +// QueryPackId is a struct representing the Resource ID for a Query Pack +type QueryPackId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string +} + +// NewQueryPackID returns a new QueryPackId struct +func NewQueryPackID(subscriptionId string, resourceGroupName string, queryPackName string) QueryPackId { + return QueryPackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + } +} + +// ParseQueryPackID parses 'input' into a QueryPackId +func ParseQueryPackID(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryPackIDInsensitively parses 'input' case-insensitively into a QueryPackId +// note: this method should only be used for API response data and not user input +func ParseQueryPackIDInsensitively(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryPackId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + return nil +} + +// ValidateQueryPackID checks that 'input' can be parsed as a Query Pack ID +func ValidateQueryPackID(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 := ParseQueryPackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query Pack ID +func (id QueryPackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query Pack ID +func (id QueryPackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + } +} + +// String returns a human-readable description of this Query Pack ID +func (id QueryPackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + } + return fmt.Sprintf("Query Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go new file mode 100644 index 00000000000..e5be1caa33a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go @@ -0,0 +1,282 @@ +package querypacks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &QueryPackId{} + +func TestNewQueryPackID(t *testing.T) { + id := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } +} + +func TestFormatQueryPackID(t *testing.T) { + actual := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryPackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestParseQueryPackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestSegmentsForQueryPackId(t *testing.T) { + segments := QueryPackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryPackId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go new file mode 100644 index 00000000000..779d071fbae --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go @@ -0,0 +1,57 @@ +package querypacks + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// CreateOrUpdate ... +func (c QueryPacksClient) CreateOrUpdate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPack) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go new file mode 100644 index 00000000000..08a4740145c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go @@ -0,0 +1,59 @@ +package querypacks + +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 CreateOrUpdateWithoutNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// CreateOrUpdateWithoutName ... +func (c QueryPacksClient) CreateOrUpdateWithoutName(ctx context.Context, id commonids.ResourceGroupId, input LogAnalyticsQueryPack) (result CreateOrUpdateWithoutNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go new file mode 100644 index 00000000000..c9137572bc3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go @@ -0,0 +1,47 @@ +package querypacks + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c QueryPacksClient) Delete(ctx context.Context, id QueryPackId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go new file mode 100644 index 00000000000..019de126545 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go @@ -0,0 +1,53 @@ +package querypacks + +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 *LogAnalyticsQueryPack +} + +// Get ... +func (c QueryPacksClient) Get(ctx context.Context, id QueryPackId) (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 LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go new file mode 100644 index 00000000000..32b92f450e9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go @@ -0,0 +1,106 @@ +package querypacks + +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 *[]LogAnalyticsQueryPack +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPack +} + +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 QueryPacksClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 *[]LogAnalyticsQueryPack `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 QueryPacksClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPacksClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LogAnalyticsQueryPackOperationPredicate) (result ListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e856e976ce0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package querypacks + +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 *[]LogAnalyticsQueryPack +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPack +} + +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 QueryPacksClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 *[]LogAnalyticsQueryPack `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 QueryPacksClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPacksClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LogAnalyticsQueryPackOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go new file mode 100644 index 00000000000..d4f83732840 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go @@ -0,0 +1,57 @@ +package querypacks + +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 UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// UpdateTags ... +func (c QueryPacksClient) UpdateTags(ctx context.Context, id QueryPackId, input TagsResource) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go new file mode 100644 index 00000000000..d71c1289066 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go @@ -0,0 +1,18 @@ +package querypacks + +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 LogAnalyticsQueryPack struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties LogAnalyticsQueryPackProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go new file mode 100644 index 00000000000..772445a81e8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go @@ -0,0 +1,41 @@ +package querypacks + +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 LogAnalyticsQueryPackProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + QueryPackId *string `json:"queryPackId,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go new file mode 100644 index 00000000000..7fdf7eeb6c5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go @@ -0,0 +1,8 @@ +package querypacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsResource struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go b/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go new file mode 100644 index 00000000000..46c21c9f019 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go @@ -0,0 +1,32 @@ +package querypacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackOperationPredicate) Matches(input LogAnalyticsQueryPack) 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/resource-manager/operationalinsights/2023-09-01/querypacks/version.go b/resource-manager/operationalinsights/2023-09-01/querypacks/version.go new file mode 100644 index 00000000000..d76fa54c4d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/version.go @@ -0,0 +1,10 @@ +package querypacks + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querypacks/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md b/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md new file mode 100644 index 00000000000..0809020bc26 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/savedsearches` Documentation + +The `savedsearches` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/savedsearches" +``` + + +### Client Initialization + +```go +client := savedsearches.NewSavedSearchesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SavedSearchesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +payload := savedsearches.SavedSearch{ + // ... +} + + +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: `SavedSearchesClient.Delete` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +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: `SavedSearchesClient.Get` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +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: `SavedSearchesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := savedsearches.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go new file mode 100644 index 00000000000..feb243cf4e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go @@ -0,0 +1,26 @@ +package savedsearches + +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 SavedSearchesClient struct { + Client *resourcemanager.Client +} + +func NewSavedSearchesClientWithBaseURI(sdkApi sdkEnv.Api) (*SavedSearchesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "savedsearches", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SavedSearchesClient: %+v", err) + } + + return &SavedSearchesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go new file mode 100644 index 00000000000..ede0c729bf5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go @@ -0,0 +1,139 @@ +package savedsearches + +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(&SavedSearchId{}) +} + +var _ resourceids.ResourceId = &SavedSearchId{} + +// SavedSearchId is a struct representing the Resource ID for a Saved Search +type SavedSearchId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + SavedSearchId string +} + +// NewSavedSearchID returns a new SavedSearchId struct +func NewSavedSearchID(subscriptionId string, resourceGroupName string, workspaceName string, savedSearchId string) SavedSearchId { + return SavedSearchId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + SavedSearchId: savedSearchId, + } +} + +// ParseSavedSearchID parses 'input' into a SavedSearchId +func ParseSavedSearchID(input string) (*SavedSearchId, error) { + parser := resourceids.NewParserFromResourceIdType(&SavedSearchId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SavedSearchId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSavedSearchIDInsensitively parses 'input' case-insensitively into a SavedSearchId +// note: this method should only be used for API response data and not user input +func ParseSavedSearchIDInsensitively(input string) (*SavedSearchId, error) { + parser := resourceids.NewParserFromResourceIdType(&SavedSearchId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SavedSearchId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SavedSearchId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.SavedSearchId, ok = input.Parsed["savedSearchId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "savedSearchId", input) + } + + return nil +} + +// ValidateSavedSearchID checks that 'input' can be parsed as a Saved Search ID +func ValidateSavedSearchID(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 := ParseSavedSearchID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Saved Search ID +func (id SavedSearchId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/savedSearches/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.SavedSearchId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Saved Search ID +func (id SavedSearchId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticSavedSearches", "savedSearches", "savedSearches"), + resourceids.UserSpecifiedSegment("savedSearchId", "savedSearchId"), + } +} + +// String returns a human-readable description of this Saved Search ID +func (id SavedSearchId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Saved Search: %q", id.SavedSearchId), + } + return fmt.Sprintf("Saved Search (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go new file mode 100644 index 00000000000..6581bd1a01b --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go @@ -0,0 +1,327 @@ +package savedsearches + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SavedSearchId{} + +func TestNewSavedSearchID(t *testing.T) { + id := NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.SavedSearchId != "savedSearchId" { + t.Fatalf("Expected %q but got %q for Segment 'SavedSearchId'", id.SavedSearchId, "savedSearchId") + } +} + +func TestFormatSavedSearchID(t *testing.T) { + actual := NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSavedSearchID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SavedSearchId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + SavedSearchId: "savedSearchId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSavedSearchID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.SavedSearchId != v.Expected.SavedSearchId { + t.Fatalf("Expected %q but got %q for SavedSearchId", v.Expected.SavedSearchId, actual.SavedSearchId) + } + + } +} + +func TestParseSavedSearchIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SavedSearchId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + SavedSearchId: "savedSearchId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs/sAvEdSeArChId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + SavedSearchId: "sAvEdSeArChId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs/sAvEdSeArChId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSavedSearchIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.SavedSearchId != v.Expected.SavedSearchId { + t.Fatalf("Expected %q but got %q for SavedSearchId", v.Expected.SavedSearchId, actual.SavedSearchId) + } + + } +} + +func TestSegmentsForSavedSearchId(t *testing.T) { + segments := SavedSearchId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SavedSearchId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go new file mode 100644 index 00000000000..bbbfffcfced --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go @@ -0,0 +1,130 @@ +package savedsearches + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go new file mode 100644 index 00000000000..906f8179a44 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go @@ -0,0 +1,282 @@ +package savedsearches + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go new file mode 100644 index 00000000000..69d3a92a12d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go @@ -0,0 +1,57 @@ +package savedsearches + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SavedSearch +} + +// CreateOrUpdate ... +func (c SavedSearchesClient) CreateOrUpdate(ctx context.Context, id SavedSearchId, input SavedSearch) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SavedSearch + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go new file mode 100644 index 00000000000..26ca123124e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go @@ -0,0 +1,46 @@ +package savedsearches + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SavedSearchesClient) Delete(ctx context.Context, id SavedSearchId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go new file mode 100644 index 00000000000..cd5ba498ecb --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go @@ -0,0 +1,53 @@ +package savedsearches + +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 *SavedSearch +} + +// Get ... +func (c SavedSearchesClient) Get(ctx context.Context, id SavedSearchId) (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 SavedSearch + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go new file mode 100644 index 00000000000..6c253f74e3a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package savedsearches + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SavedSearchesListResult +} + +// ListByWorkspace ... +func (c SavedSearchesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/savedSearches", 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 SavedSearchesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go new file mode 100644 index 00000000000..0468b07d4a2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go @@ -0,0 +1,12 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearch struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SavedSearchProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go new file mode 100644 index 00000000000..344ab1af380 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go @@ -0,0 +1,8 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearchesListResult struct { + Value *[]SavedSearch `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go new file mode 100644 index 00000000000..ab34bf3b4d1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go @@ -0,0 +1,14 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearchProperties struct { + Category string `json:"category"` + DisplayName string `json:"displayName"` + FunctionAlias *string `json:"functionAlias,omitempty"` + FunctionParameters *string `json:"functionParameters,omitempty"` + Query string `json:"query"` + Tags *[]Tag `json:"tags,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go new file mode 100644 index 00000000000..f2071dd9101 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go @@ -0,0 +1,9 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Tag struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go new file mode 100644 index 00000000000..99d62f25876 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go @@ -0,0 +1,10 @@ +package savedsearches + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/savedsearches/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md b/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md new file mode 100644 index 00000000000..00ef7012b19 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/storageinsights` Documentation + +The `storageinsights` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/storageinsights" +``` + + +### Client Initialization + +```go +client := storageinsights.NewStorageInsightsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsCreateOrUpdate` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +payload := storageinsights.StorageInsight{ + // ... +} + + +read, err := client.StorageInsightConfigsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsDelete` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +read, err := client.StorageInsightConfigsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsGet` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +read, err := client.StorageInsightConfigsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsListByWorkspace` + +```go +ctx := context.TODO() +id := storageinsights.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.StorageInsightConfigsListByWorkspace(ctx, id)` can be used to do batched pagination +items, err := client.StorageInsightConfigsListByWorkspaceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go new file mode 100644 index 00000000000..8db4661f572 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go @@ -0,0 +1,26 @@ +package storageinsights + +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 StorageInsightsClient struct { + Client *resourcemanager.Client +} + +func NewStorageInsightsClientWithBaseURI(sdkApi sdkEnv.Api) (*StorageInsightsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "storageinsights", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StorageInsightsClient: %+v", err) + } + + return &StorageInsightsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go new file mode 100644 index 00000000000..64295d09d1f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go @@ -0,0 +1,51 @@ +package storageinsights + +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 StorageInsightState string + +const ( + StorageInsightStateERROR StorageInsightState = "ERROR" + StorageInsightStateOK StorageInsightState = "OK" +) + +func PossibleValuesForStorageInsightState() []string { + return []string{ + string(StorageInsightStateERROR), + string(StorageInsightStateOK), + } +} + +func (s *StorageInsightState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageInsightState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageInsightState(input string) (*StorageInsightState, error) { + vals := map[string]StorageInsightState{ + "error": StorageInsightStateERROR, + "ok": StorageInsightStateOK, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageInsightState(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go new file mode 100644 index 00000000000..93477fb129e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go @@ -0,0 +1,139 @@ +package storageinsights + +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(&StorageInsightConfigId{}) +} + +var _ resourceids.ResourceId = &StorageInsightConfigId{} + +// StorageInsightConfigId is a struct representing the Resource ID for a Storage Insight Config +type StorageInsightConfigId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + StorageInsightConfigName string +} + +// NewStorageInsightConfigID returns a new StorageInsightConfigId struct +func NewStorageInsightConfigID(subscriptionId string, resourceGroupName string, workspaceName string, storageInsightConfigName string) StorageInsightConfigId { + return StorageInsightConfigId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + StorageInsightConfigName: storageInsightConfigName, + } +} + +// ParseStorageInsightConfigID parses 'input' into a StorageInsightConfigId +func ParseStorageInsightConfigID(input string) (*StorageInsightConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageInsightConfigId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageInsightConfigId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageInsightConfigIDInsensitively parses 'input' case-insensitively into a StorageInsightConfigId +// note: this method should only be used for API response data and not user input +func ParseStorageInsightConfigIDInsensitively(input string) (*StorageInsightConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageInsightConfigId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageInsightConfigId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageInsightConfigId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.StorageInsightConfigName, ok = input.Parsed["storageInsightConfigName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageInsightConfigName", input) + } + + return nil +} + +// ValidateStorageInsightConfigID checks that 'input' can be parsed as a Storage Insight Config ID +func ValidateStorageInsightConfigID(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 := ParseStorageInsightConfigID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Insight Config ID +func (id StorageInsightConfigId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/storageInsightConfigs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.StorageInsightConfigName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Insight Config ID +func (id StorageInsightConfigId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticStorageInsightConfigs", "storageInsightConfigs", "storageInsightConfigs"), + resourceids.UserSpecifiedSegment("storageInsightConfigName", "storageInsightConfigName"), + } +} + +// String returns a human-readable description of this Storage Insight Config ID +func (id StorageInsightConfigId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Storage Insight Config Name: %q", id.StorageInsightConfigName), + } + return fmt.Sprintf("Storage Insight Config (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go new file mode 100644 index 00000000000..286f5f06c59 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go @@ -0,0 +1,327 @@ +package storageinsights + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StorageInsightConfigId{} + +func TestNewStorageInsightConfigID(t *testing.T) { + id := NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.StorageInsightConfigName != "storageInsightConfigName" { + t.Fatalf("Expected %q but got %q for Segment 'StorageInsightConfigName'", id.StorageInsightConfigName, "storageInsightConfigName") + } +} + +func TestFormatStorageInsightConfigID(t *testing.T) { + actual := NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageInsightConfigID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageInsightConfigId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + StorageInsightConfigName: "storageInsightConfigName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageInsightConfigID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.StorageInsightConfigName != v.Expected.StorageInsightConfigName { + t.Fatalf("Expected %q but got %q for StorageInsightConfigName", v.Expected.StorageInsightConfigName, actual.StorageInsightConfigName) + } + + } +} + +func TestParseStorageInsightConfigIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageInsightConfigId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + StorageInsightConfigName: "storageInsightConfigName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs/sToRaGeInSiGhTcOnFiGnAmE", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + StorageInsightConfigName: "sToRaGeInSiGhTcOnFiGnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs/sToRaGeInSiGhTcOnFiGnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageInsightConfigIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.StorageInsightConfigName != v.Expected.StorageInsightConfigName { + t.Fatalf("Expected %q but got %q for StorageInsightConfigName", v.Expected.StorageInsightConfigName, actual.StorageInsightConfigName) + } + + } +} + +func TestSegmentsForStorageInsightConfigId(t *testing.T) { + segments := StorageInsightConfigId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageInsightConfigId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go new file mode 100644 index 00000000000..f90f45ddb97 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go @@ -0,0 +1,130 @@ +package storageinsights + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go new file mode 100644 index 00000000000..99dcec64147 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go @@ -0,0 +1,282 @@ +package storageinsights + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go new file mode 100644 index 00000000000..8f2360466e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go @@ -0,0 +1,58 @@ +package storageinsights + +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 StorageInsightConfigsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageInsight +} + +// StorageInsightConfigsCreateOrUpdate ... +func (c StorageInsightsClient) StorageInsightConfigsCreateOrUpdate(ctx context.Context, id StorageInsightConfigId, input StorageInsight) (result StorageInsightConfigsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StorageInsight + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go new file mode 100644 index 00000000000..c77f95ac83c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go @@ -0,0 +1,47 @@ +package storageinsights + +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 StorageInsightConfigsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StorageInsightConfigsDelete ... +func (c StorageInsightsClient) StorageInsightConfigsDelete(ctx context.Context, id StorageInsightConfigId) (result StorageInsightConfigsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go new file mode 100644 index 00000000000..ec74aa1f07c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go @@ -0,0 +1,53 @@ +package storageinsights + +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 StorageInsightConfigsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageInsight +} + +// StorageInsightConfigsGet ... +func (c StorageInsightsClient) StorageInsightConfigsGet(ctx context.Context, id StorageInsightConfigId) (result StorageInsightConfigsGetOperationResponse, 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 StorageInsight + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go new file mode 100644 index 00000000000..eaed4a10791 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go @@ -0,0 +1,105 @@ +package storageinsights + +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 StorageInsightConfigsListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageInsight +} + +type StorageInsightConfigsListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageInsight +} + +type StorageInsightConfigsListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *StorageInsightConfigsListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// StorageInsightConfigsListByWorkspace ... +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspace(ctx context.Context, id WorkspaceId) (result StorageInsightConfigsListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &StorageInsightConfigsListByWorkspaceCustomPager{}, + Path: fmt.Sprintf("%s/storageInsightConfigs", 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 *[]StorageInsight `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// StorageInsightConfigsListByWorkspaceComplete retrieves all the results into a single object +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (StorageInsightConfigsListByWorkspaceCompleteResult, error) { + return c.StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate(ctx, id, StorageInsightOperationPredicate{}) +} + +// StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate StorageInsightOperationPredicate) (result StorageInsightConfigsListByWorkspaceCompleteResult, err error) { + items := make([]StorageInsight, 0) + + resp, err := c.StorageInsightConfigsListByWorkspace(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 = StorageInsightConfigsListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go new file mode 100644 index 00000000000..101ce95c041 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go @@ -0,0 +1,9 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageAccount struct { + Id string `json:"id"` + Key string `json:"key"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go new file mode 100644 index 00000000000..c1d70f2d0b6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go @@ -0,0 +1,13 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsight struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageInsightProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go new file mode 100644 index 00000000000..7042ba2c8d2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go @@ -0,0 +1,11 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightProperties struct { + Containers *[]string `json:"containers,omitempty"` + Status *StorageInsightStatus `json:"status,omitempty"` + StorageAccount StorageAccount `json:"storageAccount"` + Tables *[]string `json:"tables,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go new file mode 100644 index 00000000000..33051fdac25 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go @@ -0,0 +1,9 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightStatus struct { + Description *string `json:"description,omitempty"` + State StorageInsightState `json:"state"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go new file mode 100644 index 00000000000..c926b61601e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go @@ -0,0 +1,32 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightOperationPredicate struct { + ETag *string + Id *string + Name *string + Type *string +} + +func (p StorageInsightOperationPredicate) Matches(input StorageInsight) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + 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/resource-manager/operationalinsights/2023-09-01/storageinsights/version.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/version.go new file mode 100644 index 00000000000..16f66066b96 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/version.go @@ -0,0 +1,10 @@ +package storageinsights + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/storageinsights/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/README.md b/resource-manager/operationalinsights/2023-09-01/tables/README.md new file mode 100644 index 00000000000..15cdd64f27c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/README.md @@ -0,0 +1,130 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/tables` Documentation + +The `tables` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/tables" +``` + + +### Client Initialization + +```go +client := tables.NewTablesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TablesClient.CancelSearch` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +read, err := client.CancelSearch(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +payload := tables.Table{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TablesClient.Delete` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `TablesClient.Get` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +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: `TablesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := tables.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.Migrate` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +read, err := client.Migrate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.Update` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +payload := tables.Table{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/tables/client.go b/resource-manager/operationalinsights/2023-09-01/tables/client.go new file mode 100644 index 00000000000..d448018bd46 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/client.go @@ -0,0 +1,26 @@ +package tables + +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 TablesClient struct { + Client *resourcemanager.Client +} + +func NewTablesClientWithBaseURI(sdkApi sdkEnv.Api) (*TablesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "tables", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TablesClient: %+v", err) + } + + return &TablesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/constants.go b/resource-manager/operationalinsights/2023-09-01/tables/constants.go new file mode 100644 index 00000000000..3b59c402f7c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/constants.go @@ -0,0 +1,336 @@ +package tables + +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 ColumnDataTypeHintEnum string + +const ( + ColumnDataTypeHintEnumArmPath ColumnDataTypeHintEnum = "armPath" + ColumnDataTypeHintEnumGuid ColumnDataTypeHintEnum = "guid" + ColumnDataTypeHintEnumIP ColumnDataTypeHintEnum = "ip" + ColumnDataTypeHintEnumUri ColumnDataTypeHintEnum = "uri" +) + +func PossibleValuesForColumnDataTypeHintEnum() []string { + return []string{ + string(ColumnDataTypeHintEnumArmPath), + string(ColumnDataTypeHintEnumGuid), + string(ColumnDataTypeHintEnumIP), + string(ColumnDataTypeHintEnumUri), + } +} + +func (s *ColumnDataTypeHintEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseColumnDataTypeHintEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseColumnDataTypeHintEnum(input string) (*ColumnDataTypeHintEnum, error) { + vals := map[string]ColumnDataTypeHintEnum{ + "armpath": ColumnDataTypeHintEnumArmPath, + "guid": ColumnDataTypeHintEnumGuid, + "ip": ColumnDataTypeHintEnumIP, + "uri": ColumnDataTypeHintEnumUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ColumnDataTypeHintEnum(input) + return &out, nil +} + +type ColumnTypeEnum string + +const ( + ColumnTypeEnumBoolean ColumnTypeEnum = "boolean" + ColumnTypeEnumDateTime ColumnTypeEnum = "dateTime" + ColumnTypeEnumDynamic ColumnTypeEnum = "dynamic" + ColumnTypeEnumGuid ColumnTypeEnum = "guid" + ColumnTypeEnumInt ColumnTypeEnum = "int" + ColumnTypeEnumLong ColumnTypeEnum = "long" + ColumnTypeEnumReal ColumnTypeEnum = "real" + ColumnTypeEnumString ColumnTypeEnum = "string" +) + +func PossibleValuesForColumnTypeEnum() []string { + return []string{ + string(ColumnTypeEnumBoolean), + string(ColumnTypeEnumDateTime), + string(ColumnTypeEnumDynamic), + string(ColumnTypeEnumGuid), + string(ColumnTypeEnumInt), + string(ColumnTypeEnumLong), + string(ColumnTypeEnumReal), + string(ColumnTypeEnumString), + } +} + +func (s *ColumnTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseColumnTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseColumnTypeEnum(input string) (*ColumnTypeEnum, error) { + vals := map[string]ColumnTypeEnum{ + "boolean": ColumnTypeEnumBoolean, + "datetime": ColumnTypeEnumDateTime, + "dynamic": ColumnTypeEnumDynamic, + "guid": ColumnTypeEnumGuid, + "int": ColumnTypeEnumInt, + "long": ColumnTypeEnumLong, + "real": ColumnTypeEnumReal, + "string": ColumnTypeEnumString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ColumnTypeEnum(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" + ProvisioningStateEnumUpdating ProvisioningStateEnum = "Updating" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + string(ProvisioningStateEnumUpdating), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "deleting": ProvisioningStateEnumDeleting, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + "updating": ProvisioningStateEnumUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type SourceEnum string + +const ( + SourceEnumCustomer SourceEnum = "customer" + SourceEnumMicrosoft SourceEnum = "microsoft" +) + +func PossibleValuesForSourceEnum() []string { + return []string{ + string(SourceEnumCustomer), + string(SourceEnumMicrosoft), + } +} + +func (s *SourceEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceEnum(input string) (*SourceEnum, error) { + vals := map[string]SourceEnum{ + "customer": SourceEnumCustomer, + "microsoft": SourceEnumMicrosoft, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceEnum(input) + return &out, nil +} + +type TablePlanEnum string + +const ( + TablePlanEnumAnalytics TablePlanEnum = "Analytics" + TablePlanEnumBasic TablePlanEnum = "Basic" +) + +func PossibleValuesForTablePlanEnum() []string { + return []string{ + string(TablePlanEnumAnalytics), + string(TablePlanEnumBasic), + } +} + +func (s *TablePlanEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTablePlanEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTablePlanEnum(input string) (*TablePlanEnum, error) { + vals := map[string]TablePlanEnum{ + "analytics": TablePlanEnumAnalytics, + "basic": TablePlanEnumBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TablePlanEnum(input) + return &out, nil +} + +type TableSubTypeEnum string + +const ( + TableSubTypeEnumAny TableSubTypeEnum = "Any" + TableSubTypeEnumClassic TableSubTypeEnum = "Classic" + TableSubTypeEnumDataCollectionRuleBased TableSubTypeEnum = "DataCollectionRuleBased" +) + +func PossibleValuesForTableSubTypeEnum() []string { + return []string{ + string(TableSubTypeEnumAny), + string(TableSubTypeEnumClassic), + string(TableSubTypeEnumDataCollectionRuleBased), + } +} + +func (s *TableSubTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTableSubTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTableSubTypeEnum(input string) (*TableSubTypeEnum, error) { + vals := map[string]TableSubTypeEnum{ + "any": TableSubTypeEnumAny, + "classic": TableSubTypeEnumClassic, + "datacollectionrulebased": TableSubTypeEnumDataCollectionRuleBased, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TableSubTypeEnum(input) + return &out, nil +} + +type TableTypeEnum string + +const ( + TableTypeEnumCustomLog TableTypeEnum = "CustomLog" + TableTypeEnumMicrosoft TableTypeEnum = "Microsoft" + TableTypeEnumRestoredLogs TableTypeEnum = "RestoredLogs" + TableTypeEnumSearchResults TableTypeEnum = "SearchResults" +) + +func PossibleValuesForTableTypeEnum() []string { + return []string{ + string(TableTypeEnumCustomLog), + string(TableTypeEnumMicrosoft), + string(TableTypeEnumRestoredLogs), + string(TableTypeEnumSearchResults), + } +} + +func (s *TableTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTableTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTableTypeEnum(input string) (*TableTypeEnum, error) { + vals := map[string]TableTypeEnum{ + "customlog": TableTypeEnumCustomLog, + "microsoft": TableTypeEnumMicrosoft, + "restoredlogs": TableTypeEnumRestoredLogs, + "searchresults": TableTypeEnumSearchResults, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TableTypeEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_table.go b/resource-manager/operationalinsights/2023-09-01/tables/id_table.go new file mode 100644 index 00000000000..5dbc9e51d28 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_table.go @@ -0,0 +1,139 @@ +package tables + +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(&TableId{}) +} + +var _ resourceids.ResourceId = &TableId{} + +// TableId is a struct representing the Resource ID for a Table +type TableId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + TableName string +} + +// NewTableID returns a new TableId struct +func NewTableID(subscriptionId string, resourceGroupName string, workspaceName string, tableName string) TableId { + return TableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + TableName: tableName, + } +} + +// ParseTableID parses 'input' into a TableId +func ParseTableID(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTableIDInsensitively parses 'input' case-insensitively into a TableId +// note: this method should only be used for API response data and not user input +func ParseTableIDInsensitively(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TableId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.TableName, ok = input.Parsed["tableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tableName", input) + } + + return nil +} + +// ValidateTableID checks that 'input' can be parsed as a Table ID +func ValidateTableID(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 := ParseTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Table ID +func (id TableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/tables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.TableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Table ID +func (id TableId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticTables", "tables", "tables"), + resourceids.UserSpecifiedSegment("tableName", "tableName"), + } +} + +// String returns a human-readable description of this Table ID +func (id TableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Table Name: %q", id.TableName), + } + return fmt.Sprintf("Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go b/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go new file mode 100644 index 00000000000..1cbf7d3ee33 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go @@ -0,0 +1,327 @@ +package tables + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TableId{} + +func TestNewTableID(t *testing.T) { + id := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.TableName != "tableName" { + t.Fatalf("Expected %q but got %q for Segment 'TableName'", id.TableName, "tableName") + } +} + +func TestFormatTableID(t *testing.T) { + actual := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestParseTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS/tAbLeNaMe", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + TableName: "tAbLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS/tAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestSegmentsForTableId(t *testing.T) { + segments := TableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go new file mode 100644 index 00000000000..a7abfc487d3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go @@ -0,0 +1,130 @@ +package tables + +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(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go new file mode 100644 index 00000000000..81bae7e5dab --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go @@ -0,0 +1,282 @@ +package tables + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go b/resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go new file mode 100644 index 00000000000..5268e6542a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go @@ -0,0 +1,47 @@ +package tables + +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 CancelSearchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CancelSearch ... +func (c TablesClient) CancelSearch(ctx context.Context, id TableId) (result CancelSearchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelSearch", 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/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go new file mode 100644 index 00000000000..9b7a84a5224 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go @@ -0,0 +1,75 @@ +package tables + +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 *Table +} + +// CreateOrUpdate ... +func (c TablesClient) CreateOrUpdate(ctx context.Context, id TableId, input Table) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 TablesClient) CreateOrUpdateThenPoll(ctx context.Context, id TableId, input Table) 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/resource-manager/operationalinsights/2023-09-01/tables/method_delete.go b/resource-manager/operationalinsights/2023-09-01/tables/method_delete.go new file mode 100644 index 00000000000..26e68dd6ed8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_delete.go @@ -0,0 +1,71 @@ +package tables + +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 TablesClient) Delete(ctx context.Context, id TableId) (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 TablesClient) DeleteThenPoll(ctx context.Context, id TableId) 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/resource-manager/operationalinsights/2023-09-01/tables/method_get.go b/resource-manager/operationalinsights/2023-09-01/tables/method_get.go new file mode 100644 index 00000000000..6418a17d96d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_get.go @@ -0,0 +1,53 @@ +package tables + +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 *Table +} + +// Get ... +func (c TablesClient) Get(ctx context.Context, id TableId) (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 Table + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go new file mode 100644 index 00000000000..a22495c0a5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package tables + +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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TablesListResult +} + +// ListByWorkspace ... +func (c TablesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tables", 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 TablesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go b/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go new file mode 100644 index 00000000000..af5f8e9acd1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go @@ -0,0 +1,47 @@ +package tables + +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 MigrateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Migrate ... +func (c TablesClient) Migrate(ctx context.Context, id TableId) (result MigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrate", 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/resource-manager/operationalinsights/2023-09-01/tables/method_update.go b/resource-manager/operationalinsights/2023-09-01/tables/method_update.go new file mode 100644 index 00000000000..d863c869ec7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_update.go @@ -0,0 +1,75 @@ +package tables + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Table +} + +// Update ... +func (c TablesClient) Update(ctx context.Context, id TableId, input Table) (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 TablesClient) UpdateThenPoll(ctx context.Context, id TableId, input Table) 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/resource-manager/operationalinsights/2023-09-01/tables/model_column.go b/resource-manager/operationalinsights/2023-09-01/tables/model_column.go new file mode 100644 index 00000000000..8ec13720b70 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_column.go @@ -0,0 +1,14 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Column struct { + DataTypeHint *ColumnDataTypeHintEnum `json:"dataTypeHint,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsDefaultDisplay *bool `json:"isDefaultDisplay,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + Name *string `json:"name,omitempty"` + Type *ColumnTypeEnum `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go b/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go new file mode 100644 index 00000000000..3d3bfc3f698 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go @@ -0,0 +1,41 @@ +package tables + +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 RestoredLogs struct { + AzureAsyncOperationId *string `json:"azureAsyncOperationId,omitempty"` + EndRestoreTime *string `json:"endRestoreTime,omitempty"` + SourceTable *string `json:"sourceTable,omitempty"` + StartRestoreTime *string `json:"startRestoreTime,omitempty"` +} + +func (o *RestoredLogs) GetEndRestoreTimeAsTime() (*time.Time, error) { + if o.EndRestoreTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndRestoreTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoredLogs) SetEndRestoreTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndRestoreTime = &formatted +} + +func (o *RestoredLogs) GetStartRestoreTimeAsTime() (*time.Time, error) { + if o.StartRestoreTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartRestoreTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoredLogs) SetStartRestoreTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartRestoreTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go b/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go new file mode 100644 index 00000000000..81582f6b191 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go @@ -0,0 +1,10 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResultStatistics struct { + IngestedRecords *int64 `json:"ingestedRecords,omitempty"` + Progress *float64 `json:"progress,omitempty"` + ScannedGb *float64 `json:"scannedGb,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go b/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go new file mode 100644 index 00000000000..13eb3820bd9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go @@ -0,0 +1,18 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Schema struct { + Categories *[]string `json:"categories,omitempty"` + Columns *[]Column `json:"columns,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Labels *[]string `json:"labels,omitempty"` + Name *string `json:"name,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` + Source *SourceEnum `json:"source,omitempty"` + StandardColumns *[]Column `json:"standardColumns,omitempty"` + TableSubType *TableSubTypeEnum `json:"tableSubType,omitempty"` + TableType *TableTypeEnum `json:"tableType,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go b/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go new file mode 100644 index 00000000000..8c11e8df14a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go @@ -0,0 +1,44 @@ +package tables + +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 SearchResults struct { + AzureAsyncOperationId *string `json:"azureAsyncOperationId,omitempty"` + Description *string `json:"description,omitempty"` + EndSearchTime *string `json:"endSearchTime,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Query *string `json:"query,omitempty"` + SourceTable *string `json:"sourceTable,omitempty"` + StartSearchTime *string `json:"startSearchTime,omitempty"` +} + +func (o *SearchResults) GetEndSearchTimeAsTime() (*time.Time, error) { + if o.EndSearchTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndSearchTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchResults) SetEndSearchTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndSearchTime = &formatted +} + +func (o *SearchResults) GetStartSearchTimeAsTime() (*time.Time, error) { + if o.StartSearchTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartSearchTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchResults) SetStartSearchTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartSearchTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_table.go b/resource-manager/operationalinsights/2023-09-01/tables/model_table.go new file mode 100644 index 00000000000..b74a23702c4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_table.go @@ -0,0 +1,16 @@ +package tables + +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 Table struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TableProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go b/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go new file mode 100644 index 00000000000..0b0714b4dac --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go @@ -0,0 +1,19 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableProperties struct { + ArchiveRetentionInDays *int64 `json:"archiveRetentionInDays,omitempty"` + LastPlanModifiedDate *string `json:"lastPlanModifiedDate,omitempty"` + Plan *TablePlanEnum `json:"plan,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + RestoredLogs *RestoredLogs `json:"restoredLogs,omitempty"` + ResultStatistics *ResultStatistics `json:"resultStatistics,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + RetentionInDaysAsDefault *bool `json:"retentionInDaysAsDefault,omitempty"` + Schema *Schema `json:"schema,omitempty"` + SearchResults *SearchResults `json:"searchResults,omitempty"` + TotalRetentionInDays *int64 `json:"totalRetentionInDays,omitempty"` + TotalRetentionInDaysAsDefault *bool `json:"totalRetentionInDaysAsDefault,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go b/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go new file mode 100644 index 00000000000..06dec5265ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go @@ -0,0 +1,8 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TablesListResult struct { + Value *[]Table `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/version.go b/resource-manager/operationalinsights/2023-09-01/tables/version.go new file mode 100644 index 00000000000..e6d02624abf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/version.go @@ -0,0 +1,10 @@ +package tables + +// 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-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/tables/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/README.md b/resource-manager/operationalinsights/2023-09-01/workspaces/README.md index f98a6fbd379..8b165c1dea3 100644 --- a/resource-manager/operationalinsights/2023-09-01/workspaces/README.md +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/README.md @@ -50,6 +50,22 @@ if err := client.DeleteThenPoll(ctx, id, workspaces.DefaultDeleteOperationOption ``` +### Example Usage: `WorkspacesClient.GatewaysDelete` + +```go +ctx := context.TODO() +id := workspaces.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId") + +read, err := client.GatewaysDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.Get` ```go @@ -66,6 +82,54 @@ if model := read.Model; model != nil { ``` +### Example Usage: `WorkspacesClient.IntelligencePacksDisable` + +```go +ctx := context.TODO() +id := workspaces.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.IntelligencePacksDisable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.IntelligencePacksEnable` + +```go +ctx := context.TODO() +id := workspaces.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.IntelligencePacksEnable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.IntelligencePacksList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.IntelligencePacksList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.List` ```go @@ -98,6 +162,70 @@ if model := read.Model; model != nil { ``` +### Example Usage: `WorkspacesClient.ManagementGroupsList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ManagementGroupsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SchemaGet` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SchemaGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SharedKeysGetSharedKeys` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SharedKeysGetSharedKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SharedKeysRegenerate` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SharedKeysRegenerate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.Update` ```go @@ -117,3 +245,56 @@ if model := read.Model; model != nil { // do something with the model/response object } ``` + + +### Example Usage: `WorkspacesClient.UsagesList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.UsagesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.WorkspacePurgeGetPurgeStatus` + +```go +ctx := context.TODO() +id := workspaces.NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId") + +read, err := client.WorkspacePurgeGetPurgeStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.WorkspacePurgePurge` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspaces.WorkspacePurgeBody{ + // ... +} + + +read, err := client.WorkspacePurgePurge(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go b/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go index 220d049d398..f9a609da7dc 100644 --- a/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go @@ -135,6 +135,88 @@ func parsePublicNetworkAccessType(input string) (*PublicNetworkAccessType, error return &out, nil } +type PurgeState string + +const ( + PurgeStateCompleted PurgeState = "completed" + PurgeStatePending PurgeState = "pending" +) + +func PossibleValuesForPurgeState() []string { + return []string{ + string(PurgeStateCompleted), + string(PurgeStatePending), + } +} + +func (s *PurgeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePurgeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePurgeState(input string) (*PurgeState, error) { + vals := map[string]PurgeState{ + "completed": PurgeStateCompleted, + "pending": PurgeStatePending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PurgeState(input) + return &out, nil +} + +type SearchSortEnum string + +const ( + SearchSortEnumAsc SearchSortEnum = "asc" + SearchSortEnumDesc SearchSortEnum = "desc" +) + +func PossibleValuesForSearchSortEnum() []string { + return []string{ + string(SearchSortEnumAsc), + string(SearchSortEnumDesc), + } +} + +func (s *SearchSortEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchSortEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchSortEnum(input string) (*SearchSortEnum, error) { + vals := map[string]SearchSortEnum{ + "asc": SearchSortEnumAsc, + "desc": SearchSortEnumDesc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchSortEnum(input) + return &out, nil +} + type WorkspaceEntityStatus string const ( diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go new file mode 100644 index 00000000000..ca187d0ee65 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go @@ -0,0 +1,139 @@ +package workspaces + +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(&GatewayId{}) +} + +var _ resourceids.ResourceId = &GatewayId{} + +// GatewayId is a struct representing the Resource ID for a Gateway +type GatewayId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + GatewayId string +} + +// NewGatewayID returns a new GatewayId struct +func NewGatewayID(subscriptionId string, resourceGroupName string, workspaceName string, gatewayId string) GatewayId { + return GatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + GatewayId: gatewayId, + } +} + +// ParseGatewayID parses 'input' into a GatewayId +func ParseGatewayID(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGatewayIDInsensitively parses 'input' case-insensitively into a GatewayId +// note: this method should only be used for API response data and not user input +func ParseGatewayIDInsensitively(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GatewayId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.GatewayId, ok = input.Parsed["gatewayId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayId", input) + } + + return nil +} + +// ValidateGatewayID checks that 'input' can be parsed as a Gateway ID +func ValidateGatewayID(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 := ParseGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gateway ID +func (id GatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.GatewayId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gateway ID +func (id GatewayId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayId", "gatewayId"), + } +} + +// String returns a human-readable description of this Gateway ID +func (id GatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Gateway: %q", id.GatewayId), + } + return fmt.Sprintf("Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go new file mode 100644 index 00000000000..f74a41b0227 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go @@ -0,0 +1,327 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &GatewayId{} + +func TestNewGatewayID(t *testing.T) { + id := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.GatewayId != "gatewayId" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayId'", id.GatewayId, "gatewayId") + } +} + +func TestFormatGatewayID(t *testing.T) { + actual := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + GatewayId: "gatewayId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GatewayId != v.Expected.GatewayId { + t.Fatalf("Expected %q but got %q for GatewayId", v.Expected.GatewayId, actual.GatewayId) + } + + } +} + +func TestParseGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + GatewayId: "gatewayId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS/gAtEwAyId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + GatewayId: "gAtEwAyId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS/gAtEwAyId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GatewayId != v.Expected.GatewayId { + t.Fatalf("Expected %q but got %q for GatewayId", v.Expected.GatewayId, actual.GatewayId) + } + + } +} + +func TestSegmentsForGatewayId(t *testing.T) { + segments := GatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go new file mode 100644 index 00000000000..5a01f4d44e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go @@ -0,0 +1,139 @@ +package workspaces + +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(&IntelligencePackId{}) +} + +var _ resourceids.ResourceId = &IntelligencePackId{} + +// IntelligencePackId is a struct representing the Resource ID for a Intelligence Pack +type IntelligencePackId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IntelligencePackName string +} + +// NewIntelligencePackID returns a new IntelligencePackId struct +func NewIntelligencePackID(subscriptionId string, resourceGroupName string, workspaceName string, intelligencePackName string) IntelligencePackId { + return IntelligencePackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IntelligencePackName: intelligencePackName, + } +} + +// ParseIntelligencePackID parses 'input' into a IntelligencePackId +func ParseIntelligencePackID(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIntelligencePackIDInsensitively parses 'input' case-insensitively into a IntelligencePackId +// note: this method should only be used for API response data and not user input +func ParseIntelligencePackIDInsensitively(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IntelligencePackId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.IntelligencePackName, ok = input.Parsed["intelligencePackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "intelligencePackName", input) + } + + return nil +} + +// ValidateIntelligencePackID checks that 'input' can be parsed as a Intelligence Pack ID +func ValidateIntelligencePackID(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 := ParseIntelligencePackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Intelligence Pack ID +func (id IntelligencePackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/intelligencePacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IntelligencePackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Intelligence Pack ID +func (id IntelligencePackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticIntelligencePacks", "intelligencePacks", "intelligencePacks"), + resourceids.UserSpecifiedSegment("intelligencePackName", "intelligencePackName"), + } +} + +// String returns a human-readable description of this Intelligence Pack ID +func (id IntelligencePackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Intelligence Pack Name: %q", id.IntelligencePackName), + } + return fmt.Sprintf("Intelligence Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go new file mode 100644 index 00000000000..12c700c9652 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go @@ -0,0 +1,327 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IntelligencePackId{} + +func TestNewIntelligencePackID(t *testing.T) { + id := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.IntelligencePackName != "intelligencePackName" { + t.Fatalf("Expected %q but got %q for Segment 'IntelligencePackName'", id.IntelligencePackName, "intelligencePackName") + } +} + +func TestFormatIntelligencePackID(t *testing.T) { + actual := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIntelligencePackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestParseIntelligencePackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + IntelligencePackName: "iNtElLiGeNcEpAcKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestSegmentsForIntelligencePackId(t *testing.T) { + segments := IntelligencePackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IntelligencePackId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go new file mode 100644 index 00000000000..4a9ea94f6bb --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go @@ -0,0 +1,139 @@ +package workspaces + +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(&OperationId{}) +} + +var _ resourceids.ResourceId = &OperationId{} + +// OperationId is a struct representing the Resource ID for a Operation +type OperationId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PurgeId string +} + +// NewOperationID returns a new OperationId struct +func NewOperationID(subscriptionId string, resourceGroupName string, workspaceName string, purgeId string) OperationId { + return OperationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PurgeId: purgeId, + } +} + +// ParseOperationID parses 'input' into a OperationId +func ParseOperationID(input string) (*OperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOperationIDInsensitively parses 'input' case-insensitively into a OperationId +// note: this method should only be used for API response data and not user input +func ParseOperationIDInsensitively(input string) (*OperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OperationId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PurgeId, ok = input.Parsed["purgeId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "purgeId", input) + } + + return nil +} + +// ValidateOperationID checks that 'input' can be parsed as a Operation ID +func ValidateOperationID(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 := ParseOperationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Operation ID +func (id OperationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/operations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.PurgeId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Operation ID +func (id OperationId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOperations", "operations", "operations"), + resourceids.UserSpecifiedSegment("purgeId", "purgeId"), + } +} + +// String returns a human-readable description of this Operation ID +func (id OperationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Purge: %q", id.PurgeId), + } + return fmt.Sprintf("Operation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go new file mode 100644 index 00000000000..17ff4a0877f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go @@ -0,0 +1,327 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OperationId{} + +func TestNewOperationID(t *testing.T) { + id := NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.PurgeId != "purgeId" { + t.Fatalf("Expected %q but got %q for Segment 'PurgeId'", id.PurgeId, "purgeId") + } +} + +func TestFormatOperationID(t *testing.T) { + actual := NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOperationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PurgeId: "purgeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PurgeId != v.Expected.PurgeId { + t.Fatalf("Expected %q but got %q for PurgeId", v.Expected.PurgeId, actual.PurgeId) + } + + } +} + +func TestParseOperationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PurgeId: "purgeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS/pUrGeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + PurgeId: "pUrGeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS/pUrGeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PurgeId != v.Expected.PurgeId { + t.Fatalf("Expected %q but got %q for PurgeId", v.Expected.PurgeId, actual.PurgeId) + } + + } +} + +func TestSegmentsForOperationId(t *testing.T) { + segments := OperationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OperationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go new file mode 100644 index 00000000000..2566a120d43 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go @@ -0,0 +1,46 @@ +package workspaces + +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 GatewaysDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GatewaysDelete ... +func (c WorkspacesClient) GatewaysDelete(ctx context.Context, id GatewayId) (result GatewaysDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go new file mode 100644 index 00000000000..ebf2ccdc377 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go @@ -0,0 +1,47 @@ +package workspaces + +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 IntelligencePacksDisableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// IntelligencePacksDisable ... +func (c WorkspacesClient) IntelligencePacksDisable(ctx context.Context, id IntelligencePackId) (result IntelligencePacksDisableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go new file mode 100644 index 00000000000..b28e1309455 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go @@ -0,0 +1,47 @@ +package workspaces + +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 IntelligencePacksEnableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// IntelligencePacksEnable ... +func (c WorkspacesClient) IntelligencePacksEnable(ctx context.Context, id IntelligencePackId) (result IntelligencePacksEnableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enable", 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/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go new file mode 100644 index 00000000000..1e92df537ca --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go @@ -0,0 +1,54 @@ +package workspaces + +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 IntelligencePacksListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IntelligencePack +} + +// IntelligencePacksList ... +func (c WorkspacesClient) IntelligencePacksList(ctx context.Context, id WorkspaceId) (result IntelligencePacksListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/intelligencePacks", 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 []IntelligencePack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go new file mode 100644 index 00000000000..596c5d1dab1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go @@ -0,0 +1,54 @@ +package workspaces + +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 ManagementGroupsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceListManagementGroupsResult +} + +// ManagementGroupsList ... +func (c WorkspacesClient) ManagementGroupsList(ctx context.Context, id WorkspaceId) (result ManagementGroupsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managementGroups", 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 WorkspaceListManagementGroupsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go new file mode 100644 index 00000000000..eb7127f39af --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go @@ -0,0 +1,54 @@ +package workspaces + +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 SchemaGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SearchGetSchemaResponse +} + +// SchemaGet ... +func (c WorkspacesClient) SchemaGet(ctx context.Context, id WorkspaceId) (result SchemaGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/schema", 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 SearchGetSchemaResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go new file mode 100644 index 00000000000..91f8d2b6d41 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go @@ -0,0 +1,54 @@ +package workspaces + +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 SharedKeysGetSharedKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedKeys +} + +// SharedKeysGetSharedKeys ... +func (c WorkspacesClient) SharedKeysGetSharedKeys(ctx context.Context, id WorkspaceId) (result SharedKeysGetSharedKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sharedKeys", 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 SharedKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go new file mode 100644 index 00000000000..df4473f5007 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go @@ -0,0 +1,54 @@ +package workspaces + +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 SharedKeysRegenerateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedKeys +} + +// SharedKeysRegenerate ... +func (c WorkspacesClient) SharedKeysRegenerate(ctx context.Context, id WorkspaceId) (result SharedKeysRegenerateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSharedKey", 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 SharedKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go new file mode 100644 index 00000000000..16742cf7284 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go @@ -0,0 +1,54 @@ +package workspaces + +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 UsagesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceListUsagesResult +} + +// UsagesList ... +func (c WorkspacesClient) UsagesList(ctx context.Context, id WorkspaceId) (result UsagesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", 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 WorkspaceListUsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go new file mode 100644 index 00000000000..223c603de91 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go @@ -0,0 +1,53 @@ +package workspaces + +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 WorkspacePurgeGetPurgeStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspacePurgeStatusResponse +} + +// WorkspacePurgeGetPurgeStatus ... +func (c WorkspacesClient) WorkspacePurgeGetPurgeStatus(ctx context.Context, id OperationId) (result WorkspacePurgeGetPurgeStatusOperationResponse, 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 WorkspacePurgeStatusResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go new file mode 100644 index 00000000000..2899a83661e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go @@ -0,0 +1,58 @@ +package workspaces + +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 WorkspacePurgePurgeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspacePurgeResponse +} + +// WorkspacePurgePurge ... +func (c WorkspacesClient) WorkspacePurgePurge(ctx context.Context, id WorkspaceId, input WorkspacePurgeBody) (result WorkspacePurgePurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", 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 WorkspacePurgeResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go new file mode 100644 index 00000000000..df29cb10b50 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CoreSummary struct { + NumberOfDocuments int64 `json:"numberOfDocuments"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go new file mode 100644 index 00000000000..813f158bed6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IntelligencePack struct { + DisplayName *string `json:"displayName,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go new file mode 100644 index 00000000000..dcb938c5793 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroup struct { + Properties *ManagementGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go new file mode 100644 index 00000000000..3d1b0b13e6e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go @@ -0,0 +1,45 @@ +package workspaces + +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 ManagementGroupProperties struct { + Created *string `json:"created,omitempty"` + DataReceived *string `json:"dataReceived,omitempty"` + Id *string `json:"id,omitempty"` + IsGateway *bool `json:"isGateway,omitempty"` + Name *string `json:"name,omitempty"` + ServerCount *int64 `json:"serverCount,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ManagementGroupProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagementGroupProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} + +func (o *ManagementGroupProperties) GetDataReceivedAsTime() (*time.Time, error) { + if o.DataReceived == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataReceived, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagementGroupProperties) SetDataReceivedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataReceived = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go new file mode 100644 index 00000000000..f33cbbc5f5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go new file mode 100644 index 00000000000..5cdb4d9f35d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchGetSchemaResponse struct { + Metadata *SearchMetadata `json:"metadata,omitempty"` + Value *[]SearchSchemaValue `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go new file mode 100644 index 00000000000..0929b2438d0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go @@ -0,0 +1,54 @@ +package workspaces + +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 SearchMetadata struct { + AggregatedGroupingFields *string `json:"aggregatedGroupingFields,omitempty"` + AggregatedValueField *string `json:"aggregatedValueField,omitempty"` + CoreSummaries *[]CoreSummary `json:"coreSummaries,omitempty"` + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + Max *int64 `json:"max,omitempty"` + RequestId *string `json:"requestId,omitempty"` + RequestTime *int64 `json:"requestTime,omitempty"` + ResultType *string `json:"resultType,omitempty"` + Schema *SearchMetadataSchema `json:"schema,omitempty"` + Sort *[]SearchSort `json:"sort,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + Sum *int64 `json:"sum,omitempty"` + Top *int64 `json:"top,omitempty"` + Total *int64 `json:"total,omitempty"` +} + +func (o *SearchMetadata) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchMetadata) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} + +func (o *SearchMetadata) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchMetadata) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go new file mode 100644 index 00000000000..0e39da0d0e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchMetadataSchema struct { + Name *string `json:"name,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go new file mode 100644 index 00000000000..86826b00b37 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go @@ -0,0 +1,14 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchSchemaValue struct { + DisplayName *string `json:"displayName,omitempty"` + Facet bool `json:"facet"` + Indexed bool `json:"indexed"` + Name *string `json:"name,omitempty"` + OwnerType *[]string `json:"ownerType,omitempty"` + Stored bool `json:"stored"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go new file mode 100644 index 00000000000..a7740dc9365 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchSort struct { + Name *string `json:"name,omitempty"` + Order *SearchSortEnum `json:"order,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go new file mode 100644 index 00000000000..c11550ea99e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedKeys struct { + PrimarySharedKey *string `json:"primarySharedKey,omitempty"` + SecondarySharedKey *string `json:"secondarySharedKey,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go new file mode 100644 index 00000000000..c2fb1de1937 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go @@ -0,0 +1,31 @@ +package workspaces + +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 UsageMetric struct { + CurrentValue *float64 `json:"currentValue,omitempty"` + Limit *float64 `json:"limit,omitempty"` + Name *MetricName `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *UsageMetric) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsageMetric) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go new file mode 100644 index 00000000000..101e18a9b88 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceListManagementGroupsResult struct { + Value *[]ManagementGroup `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go new file mode 100644 index 00000000000..2a0beb349b1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceListUsagesResult struct { + Value *[]UsageMetric `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go new file mode 100644 index 00000000000..338b9dd175c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeBody struct { + Filters []WorkspacePurgeBodyFilters `json:"filters"` + Table string `json:"table"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go new file mode 100644 index 00000000000..a9cded5abc2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeBodyFilters struct { + Column *string `json:"column,omitempty"` + Key *string `json:"key,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go new file mode 100644 index 00000000000..0187a62e139 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeResponse struct { + OperationId string `json:"operationId"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go new file mode 100644 index 00000000000..b4c34494dc2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeStatusResponse struct { + Status PurgeState `json:"status"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go index 901e37d3b14..7be031b5131 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasecharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go index 075fdf79954..f55ed168e3f 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasenationalcharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseNationalCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go index 0a7cad672e7..a3d0639949b 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go @@ -9,5 +9,5 @@ type AutonomousDbVersionProperties struct { IsDefaultForPaid *bool `json:"isDefaultForPaid,omitempty"` IsFreeTierEnabled *bool `json:"isFreeTierEnabled,omitempty"` IsPaidEnabled *bool `json:"isPaidEnabled,omitempty"` - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go index 57c6546805b..f8ed526badb 100644 --- a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go @@ -17,34 +17,31 @@ type DbNodeProperties struct { CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` DbServerId *string `json:"dbServerId,omitempty"` - DbSystemId *string `json:"dbSystemId,omitempty"` + DbSystemId string `json:"dbSystemId"` FaultDomain *string `json:"faultDomain,omitempty"` HostIPId *string `json:"hostIpId,omitempty"` Hostname *string `json:"hostname,omitempty"` LifecycleDetails *string `json:"lifecycleDetails,omitempty"` - LifecycleState *DbNodeProvisioningState `json:"lifecycleState,omitempty"` + LifecycleState DbNodeProvisioningState `json:"lifecycleState"` MaintenanceType *DbNodeMaintenanceType `json:"maintenanceType,omitempty"` MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` - Ocid *string `json:"ocid,omitempty"` + Ocid string `json:"ocid"` ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` SoftwareStorageSizeInGb *int64 `json:"softwareStorageSizeInGb,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` + TimeCreated string `json:"timeCreated"` TimeMaintenanceWindowEnd *string `json:"timeMaintenanceWindowEnd,omitempty"` TimeMaintenanceWindowStart *string `json:"timeMaintenanceWindowStart,omitempty"` Vnic2Id *string `json:"vnic2Id,omitempty"` - VnicId *string `json:"vnicId,omitempty"` + VnicId string `json:"vnicId"` } func (o *DbNodeProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DbNodeProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DbNodeProperties) GetTimeMaintenanceWindowEndAsTime() (*time.Time, error) { diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go index a7642317091..126cec39c37 100644 --- a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go @@ -4,7 +4,7 @@ package dbsystemshapes // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DbSystemShapeProperties struct { - AvailableCoreCount *int64 `json:"availableCoreCount,omitempty"` + AvailableCoreCount int64 `json:"availableCoreCount"` AvailableCoreCountPerNode *int64 `json:"availableCoreCountPerNode,omitempty"` AvailableDataStorageInTbs *int64 `json:"availableDataStorageInTbs,omitempty"` AvailableDataStoragePerServerInTbs *float64 `json:"availableDataStoragePerServerInTbs,omitempty"` diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go index 40cd3cf0a93..6f06446ebce 100644 --- a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go @@ -10,36 +10,30 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateViewProperties struct { - DisplayName *string `json:"displayName,omitempty"` - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateViewsLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - TimeUpdated *string `json:"timeUpdated,omitempty"` + DisplayName string `json:"displayName"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateViewsLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + TimeCreated string `json:"timeCreated"` + TimeUpdated string `json:"timeUpdated"` } func (o *DnsPrivateViewProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DnsPrivateViewProperties) GetTimeUpdatedAsTime() (*time.Time, error) { - if o.TimeUpdated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeUpdated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeUpdated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeUpdatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeUpdated = &formatted + o.TimeUpdated = formatted } diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go index 680bff102fe..5c84986be86 100644 --- a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go @@ -10,26 +10,23 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateZoneProperties struct { - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateZonesLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - Serial *int64 `json:"serial,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - Version *string `json:"version,omitempty"` - ViewId *string `json:"viewId,omitempty"` - ZoneType *ZoneType `json:"zoneType,omitempty"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateZonesLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + Serial int64 `json:"serial"` + TimeCreated string `json:"timeCreated"` + Version string `json:"version"` + ViewId *string `json:"viewId,omitempty"` + ZoneType ZoneType `json:"zoneType"` } func (o *DnsPrivateZoneProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateZoneProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go index ca86e602826..0a54f3aaee2 100644 --- a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go @@ -4,5 +4,5 @@ package giversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type GiVersionProperties struct { - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go index 5eda0476133..2684d8672ad 100644 --- a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go @@ -4,5 +4,5 @@ package systemversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type SystemVersionProperties struct { - SystemVersion *string `json:"systemVersion,omitempty"` + SystemVersion string `json:"systemVersion"` } diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/README.md b/resource-manager/search/2024-06-01-preview/adminkeys/README.md new file mode 100644 index 00000000000..82a82a5f648 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/adminkeys` Documentation + +The `adminkeys` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/adminkeys" +``` + + +### Client Initialization + +```go +client := adminkeys.NewAdminKeysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdminKeysClient.Get` + +```go +ctx := context.TODO() +id := adminkeys.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Get(ctx, id, adminkeys.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminKeysClient.Regenerate` + +```go +ctx := context.TODO() +id := adminkeys.NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary") + +read, err := client.Regenerate(ctx, id, adminkeys.DefaultRegenerateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/client.go b/resource-manager/search/2024-06-01-preview/adminkeys/client.go new file mode 100644 index 00000000000..9107624f0f1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/client.go @@ -0,0 +1,26 @@ +package adminkeys + +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 AdminKeysClient struct { + Client *resourcemanager.Client +} + +func NewAdminKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*AdminKeysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "adminkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdminKeysClient: %+v", err) + } + + return &AdminKeysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/constants.go b/resource-manager/search/2024-06-01-preview/adminkeys/constants.go new file mode 100644 index 00000000000..e56b7ce771e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/constants.go @@ -0,0 +1,51 @@ +package adminkeys + +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 AdminKeyKind string + +const ( + AdminKeyKindPrimary AdminKeyKind = "primary" + AdminKeyKindSecondary AdminKeyKind = "secondary" +) + +func PossibleValuesForAdminKeyKind() []string { + return []string{ + string(AdminKeyKindPrimary), + string(AdminKeyKindSecondary), + } +} + +func (s *AdminKeyKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdminKeyKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdminKeyKind(input string) (*AdminKeyKind, error) { + vals := map[string]AdminKeyKind{ + "primary": AdminKeyKindPrimary, + "secondary": AdminKeyKindSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdminKeyKind(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go new file mode 100644 index 00000000000..2d72e49e661 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go @@ -0,0 +1,147 @@ +package adminkeys + +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(&KeyKindId{}) +} + +var _ resourceids.ResourceId = &KeyKindId{} + +// KeyKindId is a struct representing the Resource ID for a Key Kind +type KeyKindId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + KeyKind AdminKeyKind +} + +// NewKeyKindID returns a new KeyKindId struct +func NewKeyKindID(subscriptionId string, resourceGroupName string, searchServiceName string, keyKind AdminKeyKind) KeyKindId { + return KeyKindId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + KeyKind: keyKind, + } +} + +// ParseKeyKindID parses 'input' into a KeyKindId +func ParseKeyKindID(input string) (*KeyKindId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyKindId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyKindId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKeyKindIDInsensitively parses 'input' case-insensitively into a KeyKindId +// note: this method should only be used for API response data and not user input +func ParseKeyKindIDInsensitively(input string) (*KeyKindId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyKindId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyKindId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KeyKindId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if v, ok := input.Parsed["keyKind"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyKind", input) + } + + keyKind, err := parseAdminKeyKind(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.KeyKind = *keyKind + } + + return nil +} + +// ValidateKeyKindID checks that 'input' can be parsed as a Key Kind ID +func ValidateKeyKindID(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 := ParseKeyKindID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Key Kind ID +func (id KeyKindId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/regenerateAdminKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, string(id.KeyKind)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Key Kind ID +func (id KeyKindId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticRegenerateAdminKey", "regenerateAdminKey", "regenerateAdminKey"), + resourceids.ConstantSegment("keyKind", PossibleValuesForAdminKeyKind(), "primary"), + } +} + +// String returns a human-readable description of this Key Kind ID +func (id KeyKindId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Key Kind: %q", string(id.KeyKind)), + } + return fmt.Sprintf("Key Kind (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go new file mode 100644 index 00000000000..656c1a2028d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go @@ -0,0 +1,327 @@ +package adminkeys + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &KeyKindId{} + +func TestNewKeyKindID(t *testing.T) { + id := NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.KeyKind != "primary" { + t.Fatalf("Expected %q but got %q for Segment 'KeyKind'", id.KeyKind, "primary") + } +} + +func TestFormatKeyKindID(t *testing.T) { + actual := NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKeyKindID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyKindId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + KeyKind: "primary", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyKindID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.KeyKind != v.Expected.KeyKind { + t.Fatalf("Expected %q but got %q for KeyKind", v.Expected.KeyKind, actual.KeyKind) + } + + } +} + +func TestParseKeyKindIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyKindId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + KeyKind: "primary", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY/pRiMaRy", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + KeyKind: "primary", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY/pRiMaRy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyKindIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.KeyKind != v.Expected.KeyKind { + t.Fatalf("Expected %q but got %q for KeyKind", v.Expected.KeyKind, actual.KeyKind) + } + + } +} + +func TestSegmentsForKeyKindId(t *testing.T) { + segments := KeyKindId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KeyKindId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go new file mode 100644 index 00000000000..d5042de36ef --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go @@ -0,0 +1,130 @@ +package adminkeys + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go new file mode 100644 index 00000000000..069f8b63199 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go @@ -0,0 +1,282 @@ +package adminkeys + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/method_get.go b/resource-manager/search/2024-06-01-preview/adminkeys/method_get.go new file mode 100644 index 00000000000..fde80779fd5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/method_get.go @@ -0,0 +1,83 @@ +package adminkeys + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AdminKeyResult +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c AdminKeysClient) Get(ctx context.Context, id SearchServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/listAdminKeys", 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 AdminKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go b/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go new file mode 100644 index 00000000000..9dc7bd60009 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go @@ -0,0 +1,83 @@ +package adminkeys + +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 RegenerateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AdminKeyResult +} + +type RegenerateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultRegenerateOperationOptions() RegenerateOperationOptions { + return RegenerateOperationOptions{} +} + +func (o RegenerateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o RegenerateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegenerateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Regenerate ... +func (c AdminKeysClient) Regenerate(ctx context.Context, id KeyKindId, options RegenerateOperationOptions) (result RegenerateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + 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 AdminKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go b/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go new file mode 100644 index 00000000000..0edd8c79f80 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go @@ -0,0 +1,9 @@ +package adminkeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminKeyResult struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/version.go b/resource-manager/search/2024-06-01-preview/adminkeys/version.go new file mode 100644 index 00000000000..af7cd853fda --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/version.go @@ -0,0 +1,10 @@ +package adminkeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/adminkeys/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/client.go b/resource-manager/search/2024-06-01-preview/client.go new file mode 100644 index 00000000000..7326b0f2331 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/client.go @@ -0,0 +1,91 @@ +package v2024_06_01_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/adminkeys" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/querykeys" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/services" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/usages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AdminKeys *adminkeys.AdminKeysClient + NetworkSecurityPerimeterConfigurations *networksecurityperimeterconfigurations.NetworkSecurityPerimeterConfigurationsClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + QueryKeys *querykeys.QueryKeysClient + Services *services.ServicesClient + SharedPrivateLinkResources *sharedprivatelinkresources.SharedPrivateLinkResourcesClient + Usages *usages.UsagesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + adminKeysClient, err := adminkeys.NewAdminKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AdminKeys client: %+v", err) + } + configureFunc(adminKeysClient.Client) + + networkSecurityPerimeterConfigurationsClient, err := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterConfigurations client: %+v", err) + } + configureFunc(networkSecurityPerimeterConfigurationsClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + queryKeysClient, err := querykeys.NewQueryKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryKeys client: %+v", err) + } + configureFunc(queryKeysClient.Client) + + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) + } + configureFunc(servicesClient.Client) + + sharedPrivateLinkResourcesClient, err := sharedprivatelinkresources.NewSharedPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SharedPrivateLinkResources client: %+v", err) + } + configureFunc(sharedPrivateLinkResourcesClient.Client) + + usagesClient, err := usages.NewUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Usages client: %+v", err) + } + configureFunc(usagesClient.Client) + + return &Client{ + AdminKeys: adminKeysClient, + NetworkSecurityPerimeterConfigurations: networkSecurityPerimeterConfigurationsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + QueryKeys: queryKeysClient, + Services: servicesClient, + SharedPrivateLinkResources: sharedPrivateLinkResourcesClient, + Usages: usagesClient, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md new file mode 100644 index 00000000000..c6e88d7e15f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations` Documentation + +The `networksecurityperimeterconfigurations` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/networksecurityperimeterconfigurations" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + +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: `NetworkSecurityPerimeterConfigurationsClient.ListByService` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id)` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimeterConfigurationsClient.Reconcile` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + +if err := client.ReconcileThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go new file mode 100644 index 00000000000..20530b9e06a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterconfigurations + +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 NetworkSecurityPerimeterConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterConfigurationsClient: %+v", err) + } + + return &NetworkSecurityPerimeterConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go new file mode 100644 index 00000000000..171bb79a10f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go @@ -0,0 +1,139 @@ +package networksecurityperimeterconfigurations + +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(&NetworkSecurityPerimeterConfigurationId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterConfigurationId{} + +// NetworkSecurityPerimeterConfigurationId is a struct representing the Resource ID for a Network Security Perimeter Configuration +type NetworkSecurityPerimeterConfigurationId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + NetworkSecurityPerimeterConfigurationName string +} + +// NewNetworkSecurityPerimeterConfigurationID returns a new NetworkSecurityPerimeterConfigurationId struct +func NewNetworkSecurityPerimeterConfigurationID(subscriptionId string, resourceGroupName string, searchServiceName string, networkSecurityPerimeterConfigurationName string) NetworkSecurityPerimeterConfigurationId { + return NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + NetworkSecurityPerimeterConfigurationName: networkSecurityPerimeterConfigurationName, + } +} + +// ParseNetworkSecurityPerimeterConfigurationID parses 'input' into a NetworkSecurityPerimeterConfigurationId +func ParseNetworkSecurityPerimeterConfigurationID(input string) (*NetworkSecurityPerimeterConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterConfigurationIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterConfigurationId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterConfigurationIDInsensitively(input string) (*NetworkSecurityPerimeterConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterConfigurationId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.NetworkSecurityPerimeterConfigurationName, ok = input.Parsed["networkSecurityPerimeterConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterConfigurationName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterConfigurationID checks that 'input' can be parsed as a Network Security Perimeter Configuration ID +func ValidateNetworkSecurityPerimeterConfigurationID(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 := ParseNetworkSecurityPerimeterConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/networkSecurityPerimeterConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.NetworkSecurityPerimeterConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticNetworkSecurityPerimeterConfigurations", "networkSecurityPerimeterConfigurations", "networkSecurityPerimeterConfigurations"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterConfigurationName", "networkSecurityPerimeterConfigurationName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Network Security Perimeter Configuration Name: %q", id.NetworkSecurityPerimeterConfigurationName), + } + return fmt.Sprintf("Network Security Perimeter Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go new file mode 100644 index 00000000000..5c8779f2ef4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterConfigurationId{} + +func TestNewNetworkSecurityPerimeterConfigurationID(t *testing.T) { + id := NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.NetworkSecurityPerimeterConfigurationName != "networkSecurityPerimeterConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterConfigurationName'", id.NetworkSecurityPerimeterConfigurationName, "networkSecurityPerimeterConfigurationName") + } +} + +func TestFormatNetworkSecurityPerimeterConfigurationID(t *testing.T) { + actual := NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + NetworkSecurityPerimeterConfigurationName: "networkSecurityPerimeterConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.NetworkSecurityPerimeterConfigurationName != v.Expected.NetworkSecurityPerimeterConfigurationName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterConfigurationName", v.Expected.NetworkSecurityPerimeterConfigurationName, actual.NetworkSecurityPerimeterConfigurationName) + } + + } +} + +func TestParseNetworkSecurityPerimeterConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + NetworkSecurityPerimeterConfigurationName: "networkSecurityPerimeterConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + NetworkSecurityPerimeterConfigurationName: "nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.NetworkSecurityPerimeterConfigurationName != v.Expected.NetworkSecurityPerimeterConfigurationName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterConfigurationName", v.Expected.NetworkSecurityPerimeterConfigurationName, actual.NetworkSecurityPerimeterConfigurationName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterConfigurationId(t *testing.T) { + segments := NetworkSecurityPerimeterConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go new file mode 100644 index 00000000000..3013fe00c26 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go @@ -0,0 +1,130 @@ +package networksecurityperimeterconfigurations + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go new file mode 100644 index 00000000000..80787fc0333 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go new file mode 100644 index 00000000000..ff7885e0a3d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterconfigurations + +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 *NetworkSecurityPerimeterConfiguration +} + +// Get ... +func (c NetworkSecurityPerimeterConfigurationsClient) Get(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) (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 NetworkSecurityPerimeterConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go new file mode 100644 index 00000000000..efd3fd70917 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go @@ -0,0 +1,105 @@ +package networksecurityperimeterconfigurations + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityPerimeterConfiguration +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityPerimeterConfiguration +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c NetworkSecurityPerimeterConfigurationsClient) ListByService(ctx context.Context, id SearchServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/networkSecurityPerimeterConfigurations", 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 *[]NetworkSecurityPerimeterConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterConfigurationsClient) ListByServiceComplete(ctx context.Context, id SearchServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, NetworkSecurityPerimeterConfigurationOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterConfigurationsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, predicate NetworkSecurityPerimeterConfigurationOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NetworkSecurityPerimeterConfiguration, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go new file mode 100644 index 00000000000..45935ee0f4b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go @@ -0,0 +1,69 @@ +package networksecurityperimeterconfigurations + +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 ReconcileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Reconcile ... +func (c NetworkSecurityPerimeterConfigurationsClient) Reconcile(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) (result ReconcileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconcile", 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 +} + +// ReconcileThenPoll performs Reconcile then polls until it's completed +func (c NetworkSecurityPerimeterConfigurationsClient) ReconcileThenPoll(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) error { + result, err := c.Reconcile(ctx, id) + if err != nil { + return fmt.Errorf("performing Reconcile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reconcile: %+v", err) + } + + return nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go new file mode 100644 index 00000000000..44c20a00fad --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go @@ -0,0 +1,11 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityPerimeterConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go new file mode 100644 index 00000000000..bbb025c967f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfigurationProperties struct { + NetworkSecurityPerimeter *NSPConfigPerimeter `json:"networkSecurityPerimeter,omitempty"` + Profile *NSPConfigProfile `json:"profile,omitempty"` + ProvisioningIssues *[]NSPProvisioningIssue `json:"provisioningIssues,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceAssociation *NSPConfigAssociation `json:"resourceAssociation,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go new file mode 100644 index 00000000000..0b853ab1da5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAccessRule struct { + Name *string `json:"name,omitempty"` + Properties *NSPConfigAccessRuleProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go new file mode 100644 index 00000000000..503a9df5f0c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAccessRuleProperties struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Direction *string `json:"direction,omitempty"` + FullyQualifiedDomainNames *[]string `json:"fullyQualifiedDomainNames,omitempty"` + NetworkSecurityPerimeters *[]NSPConfigNetworkSecurityPerimeterRule `json:"networkSecurityPerimeters,omitempty"` + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go new file mode 100644 index 00000000000..0322378c71b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAssociation struct { + AccessMode *string `json:"accessMode,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go new file mode 100644 index 00000000000..c529b35b6bb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigNetworkSecurityPerimeterRule struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + PerimeterGuid *string `json:"perimeterGuid,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go new file mode 100644 index 00000000000..245acf0922b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigPerimeter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + PerimeterGuid *string `json:"perimeterGuid,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go new file mode 100644 index 00000000000..91e4365d818 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigProfile struct { + AccessRules *[]NSPConfigAccessRule `json:"accessRules,omitempty"` + AccessRulesVersion *string `json:"accessRulesVersion,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go new file mode 100644 index 00000000000..522a879dcd9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPProvisioningIssue struct { + Name *string `json:"name,omitempty"` + Properties *NSPProvisioningIssueProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go new file mode 100644 index 00000000000..9d59f8ebd6b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPProvisioningIssueProperties struct { + Description *string `json:"description,omitempty"` + IssueType *string `json:"issueType,omitempty"` + Severity *string `json:"severity,omitempty"` + SuggestedAccessRules *[]string `json:"suggestedAccessRules,omitempty"` + SuggestedResourceIds *[]string `json:"suggestedResourceIds,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go new file mode 100644 index 00000000000..fd3dce574e9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NetworkSecurityPerimeterConfigurationOperationPredicate) Matches(input NetworkSecurityPerimeterConfiguration) 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/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go new file mode 100644 index 00000000000..100b2a2dacd --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterconfigurations/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md b/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md new file mode 100644 index 00000000000..453fe88c03f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +read, err := client.Delete(ctx, id, privateendpointconnections.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +read, err := client.Get(ctx, id, privateendpointconnections.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.ListByService` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id, privateendpointconnections.DefaultListByServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id, privateendpointconnections.DefaultListByServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Update` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +read, err := client.Update(ctx, id, payload, privateendpointconnections.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go new file mode 100644 index 00000000000..0a2ffc9b8d9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go @@ -0,0 +1,110 @@ +package privateendpointconnections + +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 PrivateLinkServiceConnectionProvisioningState string + +const ( + PrivateLinkServiceConnectionProvisioningStateCanceled PrivateLinkServiceConnectionProvisioningState = "Canceled" + PrivateLinkServiceConnectionProvisioningStateDeleting PrivateLinkServiceConnectionProvisioningState = "Deleting" + PrivateLinkServiceConnectionProvisioningStateFailed PrivateLinkServiceConnectionProvisioningState = "Failed" + PrivateLinkServiceConnectionProvisioningStateIncomplete PrivateLinkServiceConnectionProvisioningState = "Incomplete" + PrivateLinkServiceConnectionProvisioningStateSucceeded PrivateLinkServiceConnectionProvisioningState = "Succeeded" + PrivateLinkServiceConnectionProvisioningStateUpdating PrivateLinkServiceConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateLinkServiceConnectionProvisioningState() []string { + return []string{ + string(PrivateLinkServiceConnectionProvisioningStateCanceled), + string(PrivateLinkServiceConnectionProvisioningStateDeleting), + string(PrivateLinkServiceConnectionProvisioningStateFailed), + string(PrivateLinkServiceConnectionProvisioningStateIncomplete), + string(PrivateLinkServiceConnectionProvisioningStateSucceeded), + string(PrivateLinkServiceConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateLinkServiceConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionProvisioningState(input string) (*PrivateLinkServiceConnectionProvisioningState, error) { + vals := map[string]PrivateLinkServiceConnectionProvisioningState{ + "canceled": PrivateLinkServiceConnectionProvisioningStateCanceled, + "deleting": PrivateLinkServiceConnectionProvisioningStateDeleting, + "failed": PrivateLinkServiceConnectionProvisioningStateFailed, + "incomplete": PrivateLinkServiceConnectionProvisioningStateIncomplete, + "succeeded": PrivateLinkServiceConnectionProvisioningStateSucceeded, + "updating": PrivateLinkServiceConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..ff4fba73a97 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +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(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..22e24206c7e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go new file mode 100644 index 00000000000..61264f6abdc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go new file mode 100644 index 00000000000..f4e029064ff --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..f9336461111 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go @@ -0,0 +1,83 @@ +package privateendpointconnections + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + 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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..a1dba5099b0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go @@ -0,0 +1,83 @@ +package privateendpointconnections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId, 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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go new file mode 100644 index 00000000000..141beda1427 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go @@ -0,0 +1,134 @@ +package privateendpointconnections + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type ListByServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionsClient) ListByServiceComplete(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions, predicate PrivateEndpointConnectionOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go new file mode 100644 index 00000000000..26bcf2eb73c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go @@ -0,0 +1,87 @@ +package privateendpointconnections + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type UpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PrivateEndpointConnectionsClient) Update(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..fde7f4db0fc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..a58a78d8b1f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateLinkServiceConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go new file mode 100644 index 00000000000..f4bbf6f4340 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..b3208efc0df --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go new file mode 100644 index 00000000000..4a03a91ce52 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go @@ -0,0 +1,27 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) 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/resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go new file mode 100644 index 00000000000..0c94b8af129 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md b/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md new file mode 100644 index 00000000000..20f7029ee4c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.ListSupported` + +```go +ctx := context.TODO() +id := privatelinkresources.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.ListSupported(ctx, id, privatelinkresources.DefaultListSupportedOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +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 PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go new file mode 100644 index 00000000000..05eaeb7a093 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go @@ -0,0 +1,130 @@ +package privatelinkresources + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go new file mode 100644 index 00000000000..02832b94794 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go @@ -0,0 +1,282 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go new file mode 100644 index 00000000000..51995458025 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go @@ -0,0 +1,83 @@ +package privatelinkresources + +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 ListSupportedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesResult +} + +type ListSupportedOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListSupportedOperationOptions() ListSupportedOperationOptions { + return ListSupportedOperationOptions{} +} + +func (o ListSupportedOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListSupportedOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListSupportedOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ListSupported ... +func (c PrivateLinkResourcesClient) ListSupported(ctx context.Context, id SearchServiceId, options ListSupportedOperationOptions) (result ListSupportedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/privateLinkResources", 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 PrivateLinkResourcesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..69e8ae0e57a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..dbfb1c5c59e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go new file mode 100644 index 00000000000..bf82201cbe6 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go @@ -0,0 +1,8 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go new file mode 100644 index 00000000000..ce815b56d20 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceProperties struct { + Description *string `json:"description,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go new file mode 100644 index 00000000000..cf05c08fe62 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go @@ -0,0 +1,9 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceType struct { + Name *string `json:"name,omitempty"` + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go new file mode 100644 index 00000000000..33bc8724a14 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/README.md b/resource-manager/search/2024-06-01-preview/querykeys/README.md new file mode 100644 index 00000000000..5e1b629c4cc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/querykeys` Documentation + +The `querykeys` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/querykeys" +``` + + +### Client Initialization + +```go +client := querykeys.NewQueryKeysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryKeysClient.Create` + +```go +ctx := context.TODO() +id := querykeys.NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName") + +read, err := client.Create(ctx, id, querykeys.DefaultCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryKeysClient.Delete` + +```go +ctx := context.TODO() +id := querykeys.NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName") + +read, err := client.Delete(ctx, id, querykeys.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryKeysClient.ListBySearchService` + +```go +ctx := context.TODO() +id := querykeys.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListBySearchService(ctx, id, querykeys.DefaultListBySearchServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListBySearchServiceComplete(ctx, id, querykeys.DefaultListBySearchServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/search/2024-06-01-preview/querykeys/client.go b/resource-manager/search/2024-06-01-preview/querykeys/client.go new file mode 100644 index 00000000000..225c811f3d8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/client.go @@ -0,0 +1,26 @@ +package querykeys + +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 QueryKeysClient struct { + Client *resourcemanager.Client +} + +func NewQueryKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryKeysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querykeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryKeysClient: %+v", err) + } + + return &QueryKeysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go new file mode 100644 index 00000000000..dc859a9cb10 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go @@ -0,0 +1,139 @@ +package querykeys + +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(&CreateQueryKeyId{}) +} + +var _ resourceids.ResourceId = &CreateQueryKeyId{} + +// CreateQueryKeyId is a struct representing the Resource ID for a Create Query Key +type CreateQueryKeyId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + CreateQueryKeyName string +} + +// NewCreateQueryKeyID returns a new CreateQueryKeyId struct +func NewCreateQueryKeyID(subscriptionId string, resourceGroupName string, searchServiceName string, createQueryKeyName string) CreateQueryKeyId { + return CreateQueryKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + CreateQueryKeyName: createQueryKeyName, + } +} + +// ParseCreateQueryKeyID parses 'input' into a CreateQueryKeyId +func ParseCreateQueryKeyID(input string) (*CreateQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CreateQueryKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CreateQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCreateQueryKeyIDInsensitively parses 'input' case-insensitively into a CreateQueryKeyId +// note: this method should only be used for API response data and not user input +func ParseCreateQueryKeyIDInsensitively(input string) (*CreateQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CreateQueryKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CreateQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CreateQueryKeyId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.CreateQueryKeyName, ok = input.Parsed["createQueryKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "createQueryKeyName", input) + } + + return nil +} + +// ValidateCreateQueryKeyID checks that 'input' can be parsed as a Create Query Key ID +func ValidateCreateQueryKeyID(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 := ParseCreateQueryKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Create Query Key ID +func (id CreateQueryKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/createQueryKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.CreateQueryKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Create Query Key ID +func (id CreateQueryKeyId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticCreateQueryKey", "createQueryKey", "createQueryKey"), + resourceids.UserSpecifiedSegment("createQueryKeyName", "createQueryKeyName"), + } +} + +// String returns a human-readable description of this Create Query Key ID +func (id CreateQueryKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Create Query Key Name: %q", id.CreateQueryKeyName), + } + return fmt.Sprintf("Create Query Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go new file mode 100644 index 00000000000..4aea4df9f15 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go @@ -0,0 +1,327 @@ +package querykeys + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CreateQueryKeyId{} + +func TestNewCreateQueryKeyID(t *testing.T) { + id := NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.CreateQueryKeyName != "createQueryKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'CreateQueryKeyName'", id.CreateQueryKeyName, "createQueryKeyName") + } +} + +func TestFormatCreateQueryKeyID(t *testing.T) { + actual := NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCreateQueryKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CreateQueryKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + CreateQueryKeyName: "createQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCreateQueryKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.CreateQueryKeyName != v.Expected.CreateQueryKeyName { + t.Fatalf("Expected %q but got %q for CreateQueryKeyName", v.Expected.CreateQueryKeyName, actual.CreateQueryKeyName) + } + + } +} + +func TestParseCreateQueryKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CreateQueryKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + CreateQueryKeyName: "createQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY/cReAtEqUeRyKeYnAmE", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + CreateQueryKeyName: "cReAtEqUeRyKeYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY/cReAtEqUeRyKeYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCreateQueryKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.CreateQueryKeyName != v.Expected.CreateQueryKeyName { + t.Fatalf("Expected %q but got %q for CreateQueryKeyName", v.Expected.CreateQueryKeyName, actual.CreateQueryKeyName) + } + + } +} + +func TestSegmentsForCreateQueryKeyId(t *testing.T) { + segments := CreateQueryKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CreateQueryKeyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go new file mode 100644 index 00000000000..2d538c92b2e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go @@ -0,0 +1,139 @@ +package querykeys + +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(&DeleteQueryKeyId{}) +} + +var _ resourceids.ResourceId = &DeleteQueryKeyId{} + +// DeleteQueryKeyId is a struct representing the Resource ID for a Delete Query Key +type DeleteQueryKeyId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + DeleteQueryKeyName string +} + +// NewDeleteQueryKeyID returns a new DeleteQueryKeyId struct +func NewDeleteQueryKeyID(subscriptionId string, resourceGroupName string, searchServiceName string, deleteQueryKeyName string) DeleteQueryKeyId { + return DeleteQueryKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + DeleteQueryKeyName: deleteQueryKeyName, + } +} + +// ParseDeleteQueryKeyID parses 'input' into a DeleteQueryKeyId +func ParseDeleteQueryKeyID(input string) (*DeleteQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteQueryKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeleteQueryKeyIDInsensitively parses 'input' case-insensitively into a DeleteQueryKeyId +// note: this method should only be used for API response data and not user input +func ParseDeleteQueryKeyIDInsensitively(input string) (*DeleteQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteQueryKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeleteQueryKeyId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.DeleteQueryKeyName, ok = input.Parsed["deleteQueryKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deleteQueryKeyName", input) + } + + return nil +} + +// ValidateDeleteQueryKeyID checks that 'input' can be parsed as a Delete Query Key ID +func ValidateDeleteQueryKeyID(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 := ParseDeleteQueryKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Delete Query Key ID +func (id DeleteQueryKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/deleteQueryKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.DeleteQueryKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Delete Query Key ID +func (id DeleteQueryKeyId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticDeleteQueryKey", "deleteQueryKey", "deleteQueryKey"), + resourceids.UserSpecifiedSegment("deleteQueryKeyName", "deleteQueryKeyName"), + } +} + +// String returns a human-readable description of this Delete Query Key ID +func (id DeleteQueryKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Delete Query Key Name: %q", id.DeleteQueryKeyName), + } + return fmt.Sprintf("Delete Query Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go new file mode 100644 index 00000000000..a52be96e5e7 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go @@ -0,0 +1,327 @@ +package querykeys + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DeleteQueryKeyId{} + +func TestNewDeleteQueryKeyID(t *testing.T) { + id := NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.DeleteQueryKeyName != "deleteQueryKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'DeleteQueryKeyName'", id.DeleteQueryKeyName, "deleteQueryKeyName") + } +} + +func TestFormatDeleteQueryKeyID(t *testing.T) { + actual := NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeleteQueryKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteQueryKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + DeleteQueryKeyName: "deleteQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteQueryKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.DeleteQueryKeyName != v.Expected.DeleteQueryKeyName { + t.Fatalf("Expected %q but got %q for DeleteQueryKeyName", v.Expected.DeleteQueryKeyName, actual.DeleteQueryKeyName) + } + + } +} + +func TestParseDeleteQueryKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteQueryKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + DeleteQueryKeyName: "deleteQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY/dElEtEqUeRyKeYnAmE", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + DeleteQueryKeyName: "dElEtEqUeRyKeYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY/dElEtEqUeRyKeYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteQueryKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.DeleteQueryKeyName != v.Expected.DeleteQueryKeyName { + t.Fatalf("Expected %q but got %q for DeleteQueryKeyName", v.Expected.DeleteQueryKeyName, actual.DeleteQueryKeyName) + } + + } +} + +func TestSegmentsForDeleteQueryKeyId(t *testing.T) { + segments := DeleteQueryKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeleteQueryKeyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go new file mode 100644 index 00000000000..b68e0c91044 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go @@ -0,0 +1,130 @@ +package querykeys + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go new file mode 100644 index 00000000000..6b08f4b6112 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go @@ -0,0 +1,282 @@ +package querykeys + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/method_create.go b/resource-manager/search/2024-06-01-preview/querykeys/method_create.go new file mode 100644 index 00000000000..017b1da6e06 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_create.go @@ -0,0 +1,83 @@ +package querykeys + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QueryKey +} + +type CreateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c QueryKeysClient) Create(ctx context.Context, id CreateQueryKeyId, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + 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 QueryKey + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go b/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go new file mode 100644 index 00000000000..6b83eb0df5d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go @@ -0,0 +1,77 @@ +package querykeys + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c QueryKeysClient) Delete(ctx context.Context, id DeleteQueryKeyId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + 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 + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go b/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go new file mode 100644 index 00000000000..7419a6cdd95 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go @@ -0,0 +1,134 @@ +package querykeys + +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 ListBySearchServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]QueryKey +} + +type ListBySearchServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []QueryKey +} + +type ListBySearchServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySearchServiceOperationOptions() ListBySearchServiceOperationOptions { + return ListBySearchServiceOperationOptions{} +} + +func (o ListBySearchServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySearchServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySearchServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySearchServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySearchServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySearchService ... +func (c QueryKeysClient) ListBySearchService(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions) (result ListBySearchServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListBySearchServiceCustomPager{}, + Path: fmt.Sprintf("%s/listQueryKeys", 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 *[]QueryKey `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySearchServiceComplete retrieves all the results into a single object +func (c QueryKeysClient) ListBySearchServiceComplete(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions) (ListBySearchServiceCompleteResult, error) { + return c.ListBySearchServiceCompleteMatchingPredicate(ctx, id, options, QueryKeyOperationPredicate{}) +} + +// ListBySearchServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryKeysClient) ListBySearchServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions, predicate QueryKeyOperationPredicate) (result ListBySearchServiceCompleteResult, err error) { + items := make([]QueryKey, 0) + + resp, err := c.ListBySearchService(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 = ListBySearchServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go b/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go new file mode 100644 index 00000000000..e326c22a5fa --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go @@ -0,0 +1,9 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryKey struct { + Key *string `json:"key,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/predicates.go b/resource-manager/search/2024-06-01-preview/querykeys/predicates.go new file mode 100644 index 00000000000..6287d6738be --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/predicates.go @@ -0,0 +1,22 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryKeyOperationPredicate struct { + Key *string + Name *string +} + +func (p QueryKeyOperationPredicate) Matches(input QueryKey) bool { + + if p.Key != nil && (input.Key == nil || *p.Key != *input.Key) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/version.go b/resource-manager/search/2024-06-01-preview/querykeys/version.go new file mode 100644 index 00000000000..39441cc58a7 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/version.go @@ -0,0 +1,10 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querykeys/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/services/README.md b/resource-manager/search/2024-06-01-preview/services/README.md new file mode 100644 index 00000000000..3b6ee6af048 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/README.md @@ -0,0 +1,146 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/services` Documentation + +The `services` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/services" +``` + + +### Client Initialization + +```go +client := services.NewServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServicesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := services.CheckNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload, services.DefaultCheckNameAvailabilityOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +payload := services.SearchService{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, services.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServicesClient.Delete` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Delete(ctx, id, services.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.Get` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Get(ctx, id, services.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, services.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, services.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServicesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, services.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, services.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServicesClient.Update` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +payload := services.SearchServiceUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload, services.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/services/client.go b/resource-manager/search/2024-06-01-preview/services/client.go new file mode 100644 index 00000000000..24dd876692e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/client.go @@ -0,0 +1,26 @@ +package services + +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 ServicesClient struct { + Client *resourcemanager.Client +} + +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) + } + + return &ServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/services/constants.go b/resource-manager/search/2024-06-01-preview/services/constants.go new file mode 100644 index 00000000000..681344f8fba --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/constants.go @@ -0,0 +1,776 @@ +package services + +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 AadAuthFailureMode string + +const ( + AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge AadAuthFailureMode = "http401WithBearerChallenge" + AadAuthFailureModeHTTPFourZeroThree AadAuthFailureMode = "http403" +) + +func PossibleValuesForAadAuthFailureMode() []string { + return []string{ + string(AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge), + string(AadAuthFailureModeHTTPFourZeroThree), + } +} + +func (s *AadAuthFailureMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAadAuthFailureMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAadAuthFailureMode(input string) (*AadAuthFailureMode, error) { + vals := map[string]AadAuthFailureMode{ + "http401withbearerchallenge": AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge, + "http403": AadAuthFailureModeHTTPFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AadAuthFailureMode(input) + return &out, nil +} + +type HostingMode string + +const ( + HostingModeDefault HostingMode = "default" + HostingModeHighDensity HostingMode = "highDensity" +) + +func PossibleValuesForHostingMode() []string { + return []string{ + string(HostingModeDefault), + string(HostingModeHighDensity), + } +} + +func (s *HostingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingMode(input string) (*HostingMode, error) { + vals := map[string]HostingMode{ + "default": HostingModeDefault, + "highdensity": HostingModeHighDensity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingMode(input) + return &out, nil +} + +type PrivateLinkServiceConnectionProvisioningState string + +const ( + PrivateLinkServiceConnectionProvisioningStateCanceled PrivateLinkServiceConnectionProvisioningState = "Canceled" + PrivateLinkServiceConnectionProvisioningStateDeleting PrivateLinkServiceConnectionProvisioningState = "Deleting" + PrivateLinkServiceConnectionProvisioningStateFailed PrivateLinkServiceConnectionProvisioningState = "Failed" + PrivateLinkServiceConnectionProvisioningStateIncomplete PrivateLinkServiceConnectionProvisioningState = "Incomplete" + PrivateLinkServiceConnectionProvisioningStateSucceeded PrivateLinkServiceConnectionProvisioningState = "Succeeded" + PrivateLinkServiceConnectionProvisioningStateUpdating PrivateLinkServiceConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateLinkServiceConnectionProvisioningState() []string { + return []string{ + string(PrivateLinkServiceConnectionProvisioningStateCanceled), + string(PrivateLinkServiceConnectionProvisioningStateDeleting), + string(PrivateLinkServiceConnectionProvisioningStateFailed), + string(PrivateLinkServiceConnectionProvisioningStateIncomplete), + string(PrivateLinkServiceConnectionProvisioningStateSucceeded), + string(PrivateLinkServiceConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateLinkServiceConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionProvisioningState(input string) (*PrivateLinkServiceConnectionProvisioningState, error) { + vals := map[string]PrivateLinkServiceConnectionProvisioningState{ + "canceled": PrivateLinkServiceConnectionProvisioningStateCanceled, + "deleting": PrivateLinkServiceConnectionProvisioningStateDeleting, + "failed": PrivateLinkServiceConnectionProvisioningStateFailed, + "incomplete": PrivateLinkServiceConnectionProvisioningStateIncomplete, + "succeeded": PrivateLinkServiceConnectionProvisioningStateSucceeded, + "updating": PrivateLinkServiceConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + 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{ + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "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 PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type ResourceType string + +const ( + ResourceTypeSearchServices ResourceType = "searchServices" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeSearchServices), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "searchservices": ResourceTypeSearchServices, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} + +type SearchBypass string + +const ( + SearchBypassAzurePortal SearchBypass = "AzurePortal" + SearchBypassAzureServices SearchBypass = "AzureServices" + SearchBypassNone SearchBypass = "None" +) + +func PossibleValuesForSearchBypass() []string { + return []string{ + string(SearchBypassAzurePortal), + string(SearchBypassAzureServices), + string(SearchBypassNone), + } +} + +func (s *SearchBypass) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchBypass(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchBypass(input string) (*SearchBypass, error) { + vals := map[string]SearchBypass{ + "azureportal": SearchBypassAzurePortal, + "azureservices": SearchBypassAzureServices, + "none": SearchBypassNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchBypass(input) + return &out, nil +} + +type SearchDisabledDataExfiltrationOption string + +const ( + SearchDisabledDataExfiltrationOptionAll SearchDisabledDataExfiltrationOption = "All" +) + +func PossibleValuesForSearchDisabledDataExfiltrationOption() []string { + return []string{ + string(SearchDisabledDataExfiltrationOptionAll), + } +} + +func (s *SearchDisabledDataExfiltrationOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchDisabledDataExfiltrationOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchDisabledDataExfiltrationOption(input string) (*SearchDisabledDataExfiltrationOption, error) { + vals := map[string]SearchDisabledDataExfiltrationOption{ + "all": SearchDisabledDataExfiltrationOptionAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchDisabledDataExfiltrationOption(input) + return &out, nil +} + +type SearchEncryptionComplianceStatus string + +const ( + SearchEncryptionComplianceStatusCompliant SearchEncryptionComplianceStatus = "Compliant" + SearchEncryptionComplianceStatusNonCompliant SearchEncryptionComplianceStatus = "NonCompliant" +) + +func PossibleValuesForSearchEncryptionComplianceStatus() []string { + return []string{ + string(SearchEncryptionComplianceStatusCompliant), + string(SearchEncryptionComplianceStatusNonCompliant), + } +} + +func (s *SearchEncryptionComplianceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchEncryptionComplianceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchEncryptionComplianceStatus(input string) (*SearchEncryptionComplianceStatus, error) { + vals := map[string]SearchEncryptionComplianceStatus{ + "compliant": SearchEncryptionComplianceStatusCompliant, + "noncompliant": SearchEncryptionComplianceStatusNonCompliant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchEncryptionComplianceStatus(input) + return &out, nil +} + +type SearchEncryptionWithCmk string + +const ( + SearchEncryptionWithCmkDisabled SearchEncryptionWithCmk = "Disabled" + SearchEncryptionWithCmkEnabled SearchEncryptionWithCmk = "Enabled" + SearchEncryptionWithCmkUnspecified SearchEncryptionWithCmk = "Unspecified" +) + +func PossibleValuesForSearchEncryptionWithCmk() []string { + return []string{ + string(SearchEncryptionWithCmkDisabled), + string(SearchEncryptionWithCmkEnabled), + string(SearchEncryptionWithCmkUnspecified), + } +} + +func (s *SearchEncryptionWithCmk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchEncryptionWithCmk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchEncryptionWithCmk(input string) (*SearchEncryptionWithCmk, error) { + vals := map[string]SearchEncryptionWithCmk{ + "disabled": SearchEncryptionWithCmkDisabled, + "enabled": SearchEncryptionWithCmkEnabled, + "unspecified": SearchEncryptionWithCmkUnspecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchEncryptionWithCmk(input) + return &out, nil +} + +type SearchSemanticSearch string + +const ( + SearchSemanticSearchDisabled SearchSemanticSearch = "disabled" + SearchSemanticSearchFree SearchSemanticSearch = "free" + SearchSemanticSearchStandard SearchSemanticSearch = "standard" +) + +func PossibleValuesForSearchSemanticSearch() []string { + return []string{ + string(SearchSemanticSearchDisabled), + string(SearchSemanticSearchFree), + string(SearchSemanticSearchStandard), + } +} + +func (s *SearchSemanticSearch) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchSemanticSearch(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchSemanticSearch(input string) (*SearchSemanticSearch, error) { + vals := map[string]SearchSemanticSearch{ + "disabled": SearchSemanticSearchDisabled, + "free": SearchSemanticSearchFree, + "standard": SearchSemanticSearchStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchSemanticSearch(input) + return &out, nil +} + +type SearchServiceStatus string + +const ( + SearchServiceStatusDegraded SearchServiceStatus = "degraded" + SearchServiceStatusDeleting SearchServiceStatus = "deleting" + SearchServiceStatusDisabled SearchServiceStatus = "disabled" + SearchServiceStatusError SearchServiceStatus = "error" + SearchServiceStatusProvisioning SearchServiceStatus = "provisioning" + SearchServiceStatusRunning SearchServiceStatus = "running" + SearchServiceStatusStopped SearchServiceStatus = "stopped" +) + +func PossibleValuesForSearchServiceStatus() []string { + return []string{ + string(SearchServiceStatusDegraded), + string(SearchServiceStatusDeleting), + string(SearchServiceStatusDisabled), + string(SearchServiceStatusError), + string(SearchServiceStatusProvisioning), + string(SearchServiceStatusRunning), + string(SearchServiceStatusStopped), + } +} + +func (s *SearchServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchServiceStatus(input string) (*SearchServiceStatus, error) { + vals := map[string]SearchServiceStatus{ + "degraded": SearchServiceStatusDegraded, + "deleting": SearchServiceStatusDeleting, + "disabled": SearchServiceStatusDisabled, + "error": SearchServiceStatusError, + "provisioning": SearchServiceStatusProvisioning, + "running": SearchServiceStatusRunning, + "stopped": SearchServiceStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchServiceStatus(input) + return &out, nil +} + +type SharedPrivateLinkResourceProvisioningState string + +const ( + SharedPrivateLinkResourceProvisioningStateDeleting SharedPrivateLinkResourceProvisioningState = "Deleting" + SharedPrivateLinkResourceProvisioningStateFailed SharedPrivateLinkResourceProvisioningState = "Failed" + SharedPrivateLinkResourceProvisioningStateIncomplete SharedPrivateLinkResourceProvisioningState = "Incomplete" + SharedPrivateLinkResourceProvisioningStateSucceeded SharedPrivateLinkResourceProvisioningState = "Succeeded" + SharedPrivateLinkResourceProvisioningStateUpdating SharedPrivateLinkResourceProvisioningState = "Updating" +) + +func PossibleValuesForSharedPrivateLinkResourceProvisioningState() []string { + return []string{ + string(SharedPrivateLinkResourceProvisioningStateDeleting), + string(SharedPrivateLinkResourceProvisioningStateFailed), + string(SharedPrivateLinkResourceProvisioningStateIncomplete), + string(SharedPrivateLinkResourceProvisioningStateSucceeded), + string(SharedPrivateLinkResourceProvisioningStateUpdating), + } +} + +func (s *SharedPrivateLinkResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceProvisioningState(input string) (*SharedPrivateLinkResourceProvisioningState, error) { + vals := map[string]SharedPrivateLinkResourceProvisioningState{ + "deleting": SharedPrivateLinkResourceProvisioningStateDeleting, + "failed": SharedPrivateLinkResourceProvisioningStateFailed, + "incomplete": SharedPrivateLinkResourceProvisioningStateIncomplete, + "succeeded": SharedPrivateLinkResourceProvisioningStateSucceeded, + "updating": SharedPrivateLinkResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceProvisioningState(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "basic" + SkuNameFree SkuName = "free" + SkuNameStandard SkuName = "standard" + SkuNameStandardThree SkuName = "standard3" + SkuNameStandardTwo SkuName = "standard2" + SkuNameStorageOptimizedLOne SkuName = "storage_optimized_l1" + SkuNameStorageOptimizedLTwo SkuName = "storage_optimized_l2" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameFree), + string(SkuNameStandard), + string(SkuNameStandardThree), + string(SkuNameStandardTwo), + string(SkuNameStorageOptimizedLOne), + string(SkuNameStorageOptimizedLTwo), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "free": SkuNameFree, + "standard": SkuNameStandard, + "standard3": SkuNameStandardThree, + "standard2": SkuNameStandardTwo, + "storage_optimized_l1": SkuNameStorageOptimizedLOne, + "storage_optimized_l2": SkuNameStorageOptimizedLTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type UnavailableNameReason string + +const ( + UnavailableNameReasonAlreadyExists UnavailableNameReason = "AlreadyExists" + UnavailableNameReasonInvalid UnavailableNameReason = "Invalid" +) + +func PossibleValuesForUnavailableNameReason() []string { + return []string{ + string(UnavailableNameReasonAlreadyExists), + string(UnavailableNameReasonInvalid), + } +} + +func (s *UnavailableNameReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnavailableNameReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnavailableNameReason(input string) (*UnavailableNameReason, error) { + vals := map[string]UnavailableNameReason{ + "alreadyexists": UnavailableNameReasonAlreadyExists, + "invalid": UnavailableNameReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnavailableNameReason(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/services/id_searchservice.go b/resource-manager/search/2024-06-01-preview/services/id_searchservice.go new file mode 100644 index 00000000000..1cb359dc995 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/id_searchservice.go @@ -0,0 +1,130 @@ +package services + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go new file mode 100644 index 00000000000..b057ee877be --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go @@ -0,0 +1,282 @@ +package services + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go b/resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go new file mode 100644 index 00000000000..fc2d16f5577 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go @@ -0,0 +1,88 @@ +package services + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityOutput +} + +type CheckNameAvailabilityOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCheckNameAvailabilityOperationOptions() CheckNameAvailabilityOperationOptions { + return CheckNameAvailabilityOperationOptions{} +} + +func (o CheckNameAvailabilityOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CheckNameAvailabilityOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CheckNameAvailabilityOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CheckNameAvailability ... +func (c ServicesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityInput, options CheckNameAvailabilityOperationOptions) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.Search/checkNameAvailability", 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 CheckNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go b/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go new file mode 100644 index 00000000000..eb913bcdc6b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go @@ -0,0 +1,104 @@ +package services + +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 *SearchService +} + +type CreateOrUpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ServicesClient) CreateOrUpdate(ctx context.Context, id SearchServiceId, input SearchService, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 ServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id SearchServiceId, input SearchService, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/resource-manager/search/2024-06-01-preview/services/method_delete.go b/resource-manager/search/2024-06-01-preview/services/method_delete.go new file mode 100644 index 00000000000..da3e636b27e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_delete.go @@ -0,0 +1,77 @@ +package services + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ServicesClient) Delete(ctx context.Context, id SearchServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + 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 + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_get.go b/resource-manager/search/2024-06-01-preview/services/method_get.go new file mode 100644 index 00000000000..7d3bc50da98 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_get.go @@ -0,0 +1,83 @@ +package services + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SearchService +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c ServicesClient) Get(ctx context.Context, id SearchServiceId, 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 SearchService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go b/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e27921b39d4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package services + +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 *[]SearchService +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SearchService +} + +type ListByResourceGroupOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + 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 ServicesClient) 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.Search/searchServices", 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 *[]SearchService `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 ServicesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SearchServiceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServicesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SearchServiceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SearchService, 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/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go b/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go new file mode 100644 index 00000000000..c72273bc4d8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go @@ -0,0 +1,135 @@ +package services + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SearchService +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SearchService +} + +type ListBySubscriptionOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c ServicesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Search/searchServices", 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 *[]SearchService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ServicesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, SearchServiceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServicesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate SearchServiceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SearchService, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_update.go b/resource-manager/search/2024-06-01-preview/services/method_update.go new file mode 100644 index 00000000000..2fcfddaf54e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_update.go @@ -0,0 +1,87 @@ +package services + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SearchService +} + +type UpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ServicesClient) Update(ctx context.Context, id SearchServiceId, input SearchServiceUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SearchService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go new file mode 100644 index 00000000000..a0c8c13c73a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityInput struct { + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go new file mode 100644 index 00000000000..f10992a6cde --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOutput struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *UnavailableNameReason `json:"reason,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go b/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go new file mode 100644 index 00000000000..aa7d26142fb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPlaneAadOrApiKeyAuthOption struct { + AadAuthFailureMode *AadAuthFailureMode `json:"aadAuthFailureMode,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go b/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go new file mode 100644 index 00000000000..7a32d0d1f1d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPlaneAuthOptions struct { + AadOrApiKey *DataPlaneAadOrApiKeyAuthOption `json:"aadOrApiKey,omitempty"` + ApiKeyOnly *interface{} `json:"apiKeyOnly,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go b/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go new file mode 100644 index 00000000000..6f4bfcca62f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionWithCmk struct { + EncryptionComplianceStatus *SearchEncryptionComplianceStatus `json:"encryptionComplianceStatus,omitempty"` + Enforcement *SearchEncryptionWithCmk `json:"enforcement,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_iprule.go b/resource-manager/search/2024-06-01-preview/services/model_iprule.go new file mode 100644 index 00000000000..f05c1d347f1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_iprule.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPRule struct { + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go b/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go new file mode 100644 index 00000000000..eaba6740a80 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkRuleSet struct { + Bypass *SearchBypass `json:"bypass,omitempty"` + IPRules *[]IPRule `json:"ipRules,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go new file mode 100644 index 00000000000..bb3fe5c797d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..2e955f64b7f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateLinkServiceConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go new file mode 100644 index 00000000000..ba85df04a41 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..594793a1615 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchservice.go b/resource-manager/search/2024-06-01-preview/services/model_searchservice.go new file mode 100644 index 00000000000..6193f974ae0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchservice.go @@ -0,0 +1,19 @@ +package services + +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 SearchService struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SearchServiceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go b/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go new file mode 100644 index 00000000000..a6314f4a591 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go @@ -0,0 +1,23 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchServiceProperties struct { + AuthOptions *DataPlaneAuthOptions `json:"authOptions,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + DisabledDataExfiltrationOptions *[]SearchDisabledDataExfiltrationOption `json:"disabledDataExfiltrationOptions,omitempty"` + ETag *string `json:"eTag,omitempty"` + EncryptionWithCmk *EncryptionWithCmk `json:"encryptionWithCmk,omitempty"` + HostingMode *HostingMode `json:"hostingMode,omitempty"` + NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + PartitionCount *int64 `json:"partitionCount,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ReplicaCount *int64 `json:"replicaCount,omitempty"` + SemanticSearch *SearchSemanticSearch `json:"semanticSearch,omitempty"` + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + Status *SearchServiceStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go b/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go new file mode 100644 index 00000000000..d80e077366c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go @@ -0,0 +1,19 @@ +package services + +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 SearchServiceUpdate struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SearchServiceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..2052d81b1cb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..dcfbd937645 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,13 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + ProvisioningState *SharedPrivateLinkResourceProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + ResourceRegion *string `json:"resourceRegion,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sku.go b/resource-manager/search/2024-06-01-preview/services/model_sku.go new file mode 100644 index 00000000000..043547ca6d4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sku.go @@ -0,0 +1,8 @@ +package services + +// 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 { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/predicates.go b/resource-manager/search/2024-06-01-preview/services/predicates.go new file mode 100644 index 00000000000..8743fe1ac71 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/predicates.go @@ -0,0 +1,32 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchServiceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SearchServiceOperationPredicate) Matches(input SearchService) 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/resource-manager/search/2024-06-01-preview/services/version.go b/resource-manager/search/2024-06-01-preview/services/version.go new file mode 100644 index 00000000000..04cd96be6f5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/version.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/services/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md new file mode 100644 index 00000000000..72fa4f7fba0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources` Documentation + +The `sharedprivatelinkresources` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/sharedprivatelinkresources" +``` + + +### Client Initialization + +```go +client := sharedprivatelinkresources.NewSharedPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +payload := sharedprivatelinkresources.SharedPrivateLinkResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, sharedprivatelinkresources.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.Delete` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +if err := client.DeleteThenPoll(ctx, id, sharedprivatelinkresources.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +read, err := client.Get(ctx, id, sharedprivatelinkresources.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.ListByService` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id, sharedprivatelinkresources.DefaultListByServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id, sharedprivatelinkresources.DefaultListByServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go new file mode 100644 index 00000000000..4e06c2f4a5d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package sharedprivatelinkresources + +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 SharedPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewSharedPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*SharedPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sharedprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SharedPrivateLinkResourcesClient: %+v", err) + } + + return &SharedPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go new file mode 100644 index 00000000000..1e34bb59acc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go @@ -0,0 +1,107 @@ +package sharedprivatelinkresources + +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 SharedPrivateLinkResourceProvisioningState string + +const ( + SharedPrivateLinkResourceProvisioningStateDeleting SharedPrivateLinkResourceProvisioningState = "Deleting" + SharedPrivateLinkResourceProvisioningStateFailed SharedPrivateLinkResourceProvisioningState = "Failed" + SharedPrivateLinkResourceProvisioningStateIncomplete SharedPrivateLinkResourceProvisioningState = "Incomplete" + SharedPrivateLinkResourceProvisioningStateSucceeded SharedPrivateLinkResourceProvisioningState = "Succeeded" + SharedPrivateLinkResourceProvisioningStateUpdating SharedPrivateLinkResourceProvisioningState = "Updating" +) + +func PossibleValuesForSharedPrivateLinkResourceProvisioningState() []string { + return []string{ + string(SharedPrivateLinkResourceProvisioningStateDeleting), + string(SharedPrivateLinkResourceProvisioningStateFailed), + string(SharedPrivateLinkResourceProvisioningStateIncomplete), + string(SharedPrivateLinkResourceProvisioningStateSucceeded), + string(SharedPrivateLinkResourceProvisioningStateUpdating), + } +} + +func (s *SharedPrivateLinkResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceProvisioningState(input string) (*SharedPrivateLinkResourceProvisioningState, error) { + vals := map[string]SharedPrivateLinkResourceProvisioningState{ + "deleting": SharedPrivateLinkResourceProvisioningStateDeleting, + "failed": SharedPrivateLinkResourceProvisioningStateFailed, + "incomplete": SharedPrivateLinkResourceProvisioningStateIncomplete, + "succeeded": SharedPrivateLinkResourceProvisioningStateSucceeded, + "updating": SharedPrivateLinkResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceProvisioningState(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go new file mode 100644 index 00000000000..225d4b0ceb2 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go @@ -0,0 +1,130 @@ +package sharedprivatelinkresources + +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(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go new file mode 100644 index 00000000000..82567ff2cb0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go @@ -0,0 +1,282 @@ +package sharedprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go new file mode 100644 index 00000000000..9148a3fdf54 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go @@ -0,0 +1,139 @@ +package sharedprivatelinkresources + +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(&SharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +// SharedPrivateLinkResourceId is a struct representing the Resource ID for a Shared Private Link Resource +type SharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + SharedPrivateLinkResourceName string +} + +// NewSharedPrivateLinkResourceID returns a new SharedPrivateLinkResourceId struct +func NewSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string) SharedPrivateLinkResourceId { + return SharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseSharedPrivateLinkResourceID parses 'input' into a SharedPrivateLinkResourceId +func ParseSharedPrivateLinkResourceID(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a SharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseSharedPrivateLinkResourceIDInsensitively(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SharedPrivateLinkResourceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateSharedPrivateLinkResourceID checks that 'input' can be parsed as a Shared Private Link Resource ID +func ValidateSharedPrivateLinkResourceID(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 := ParseSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceName"), + } +} + +// String returns a human-readable description of this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go new file mode 100644 index 00000000000..7772fd93faa --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go @@ -0,0 +1,327 @@ +package sharedprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +func TestNewSharedPrivateLinkResourceID(t *testing.T) { + id := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceName") + } +} + +func TestFormatSharedPrivateLinkResourceID(t *testing.T) { + actual := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeNaMe", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForSharedPrivateLinkResourceId(t *testing.T) { + segments := SharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SharedPrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go new file mode 100644 index 00000000000..502bb307fd4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go @@ -0,0 +1,104 @@ +package sharedprivatelinkresources + +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 *SharedPrivateLinkResource +} + +type CreateOrUpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SharedPrivateLinkResourcesClient) CreateOrUpdate(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 SharedPrivateLinkResourcesClient) CreateOrUpdateThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go new file mode 100644 index 00000000000..8d405761166 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go @@ -0,0 +1,99 @@ +package sharedprivatelinkresources + +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 +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c SharedPrivateLinkResourcesClient) Delete(ctx context.Context, id SharedPrivateLinkResourceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SharedPrivateLinkResourcesClient) DeleteThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go new file mode 100644 index 00000000000..aefab346f1d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go @@ -0,0 +1,83 @@ +package sharedprivatelinkresources + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedPrivateLinkResource +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c SharedPrivateLinkResourcesClient) Get(ctx context.Context, id SharedPrivateLinkResourceId, 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 SharedPrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go new file mode 100644 index 00000000000..989aebe9b50 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go @@ -0,0 +1,134 @@ +package sharedprivatelinkresources + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +type ListByServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c SharedPrivateLinkResourcesClient) ListByService(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c SharedPrivateLinkResourcesClient) ListByServiceComplete(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, SharedPrivateLinkResourceOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SharedPrivateLinkResourcesClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions, predicate SharedPrivateLinkResourceOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..dfe11288236 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go @@ -0,0 +1,11 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..25934430949 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,13 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + ProvisioningState *SharedPrivateLinkResourceProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + ResourceRegion *string `json:"resourceRegion,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go new file mode 100644 index 00000000000..b4d0b794bcb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SharedPrivateLinkResourceOperationPredicate) Matches(input SharedPrivateLinkResource) 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/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go new file mode 100644 index 00000000000..b4bee4d183c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sharedprivatelinkresources/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/usages/README.md b/resource-manager/search/2024-06-01-preview/usages/README.md new file mode 100644 index 00000000000..7f4066c413a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/usages` Documentation + +The `usages` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/usages" +``` + + +### Client Initialization + +```go +client := usages.NewUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UsagesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := usages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListBySubscription(ctx, id, usages.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, usages.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `UsagesClient.UsageBySubscriptionSku` + +```go +ctx := context.TODO() +id := usages.NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName") + +read, err := client.UsageBySubscriptionSku(ctx, id, usages.DefaultUsageBySubscriptionSkuOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/usages/client.go b/resource-manager/search/2024-06-01-preview/usages/client.go new file mode 100644 index 00000000000..5b6ce18413b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/client.go @@ -0,0 +1,26 @@ +package usages + +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 UsagesClient struct { + Client *resourcemanager.Client +} + +func NewUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*UsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "usages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsagesClient: %+v", err) + } + + return &UsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_location.go b/resource-manager/search/2024-06-01-preview/usages/id_location.go new file mode 100644 index 00000000000..9c965faf9c6 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_location.go @@ -0,0 +1,121 @@ +package usages + +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(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Search/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_location_test.go b/resource-manager/search/2024-06-01-preview/usages/id_location_test.go new file mode 100644 index 00000000000..9542fbf99e2 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_location_test.go @@ -0,0 +1,237 @@ +package usages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_usage.go b/resource-manager/search/2024-06-01-preview/usages/id_usage.go new file mode 100644 index 00000000000..b4a582125ed --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_usage.go @@ -0,0 +1,130 @@ +package usages + +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(&UsageId{}) +} + +var _ resourceids.ResourceId = &UsageId{} + +// UsageId is a struct representing the Resource ID for a Usage +type UsageId struct { + SubscriptionId string + LocationName string + UsageName string +} + +// NewUsageID returns a new UsageId struct +func NewUsageID(subscriptionId string, locationName string, usageName string) UsageId { + return UsageId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + UsageName: usageName, + } +} + +// ParseUsageID parses 'input' into a UsageId +func ParseUsageID(input string) (*UsageId, error) { + parser := resourceids.NewParserFromResourceIdType(&UsageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UsageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUsageIDInsensitively parses 'input' case-insensitively into a UsageId +// note: this method should only be used for API response data and not user input +func ParseUsageIDInsensitively(input string) (*UsageId, error) { + parser := resourceids.NewParserFromResourceIdType(&UsageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UsageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UsageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.UsageName, ok = input.Parsed["usageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "usageName", input) + } + + return nil +} + +// ValidateUsageID checks that 'input' can be parsed as a Usage ID +func ValidateUsageID(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 := ParseUsageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Usage ID +func (id UsageId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Search/locations/%s/usages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.UsageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Usage ID +func (id UsageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticUsages", "usages", "usages"), + resourceids.UserSpecifiedSegment("usageName", "usageName"), + } +} + +// String returns a human-readable description of this Usage ID +func (id UsageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Usage Name: %q", id.UsageName), + } + return fmt.Sprintf("Usage (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go b/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go new file mode 100644 index 00000000000..1b38f124b7f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go @@ -0,0 +1,282 @@ +package usages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &UsageId{} + +func TestNewUsageID(t *testing.T) { + id := NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.UsageName != "usageName" { + t.Fatalf("Expected %q but got %q for Segment 'UsageName'", id.UsageName, "usageName") + } +} + +func TestFormatUsageID(t *testing.T) { + actual := NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUsageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UsageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + UsageName: "usageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUsageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.UsageName != v.Expected.UsageName { + t.Fatalf("Expected %q but got %q for UsageName", v.Expected.UsageName, actual.UsageName) + } + + } +} + +func TestParseUsageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UsageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + UsageName: "usageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS/uSaGeNaMe", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + UsageName: "uSaGeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS/uSaGeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUsageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.UsageName != v.Expected.UsageName { + t.Fatalf("Expected %q but got %q for UsageName", v.Expected.UsageName, actual.UsageName) + } + + } +} + +func TestSegmentsForUsageId(t *testing.T) { + segments := UsageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UsageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go b/resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go new file mode 100644 index 00000000000..086c77f98e8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go @@ -0,0 +1,134 @@ +package usages + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]QuotaUsageResult +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []QuotaUsageResult +} + +type ListBySubscriptionOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c UsagesClient) ListBySubscription(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]QuotaUsageResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c UsagesClient) ListBySubscriptionComplete(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, QuotaUsageResultOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsagesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions, predicate QuotaUsageResultOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]QuotaUsageResult, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go b/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go new file mode 100644 index 00000000000..cad37446749 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go @@ -0,0 +1,83 @@ +package usages + +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 UsageBySubscriptionSkuOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QuotaUsageResult +} + +type UsageBySubscriptionSkuOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUsageBySubscriptionSkuOperationOptions() UsageBySubscriptionSkuOperationOptions { + return UsageBySubscriptionSkuOperationOptions{} +} + +func (o UsageBySubscriptionSkuOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UsageBySubscriptionSkuOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UsageBySubscriptionSkuOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UsageBySubscriptionSku ... +func (c UsagesClient) UsageBySubscriptionSku(ctx context.Context, id UsageId, options UsageBySubscriptionSkuOperationOptions) (result UsageBySubscriptionSkuOperationResponse, 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 QuotaUsageResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go new file mode 100644 index 00000000000..d6e8cec840c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go @@ -0,0 +1,12 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResult struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *QuotaUsageResultName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go new file mode 100644 index 00000000000..b8acf6bea95 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go @@ -0,0 +1,9 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResultName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/usages/predicates.go b/resource-manager/search/2024-06-01-preview/usages/predicates.go new file mode 100644 index 00000000000..cf2a95bafc1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/predicates.go @@ -0,0 +1,32 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResultOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 + Unit *string +} + +func (p QuotaUsageResultOperationPredicate) Matches(input QuotaUsageResult) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} diff --git a/resource-manager/search/2024-06-01-preview/usages/version.go b/resource-manager/search/2024-06-01-preview/usages/version.go new file mode 100644 index 00000000000..611ce6cd051 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/version.go @@ -0,0 +1,10 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/usages/2024-06-01-preview" +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go index 3d3d567781e..c1ad7b8d50d 100644 --- a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go index e2cb7617883..1c11378cc2e 100644 --- a/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/web/2023-12-01/webapps/model_siteproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go index dcb3e020b67..7f844ec7578 100644 --- a/resource-manager/web/2023-12-01/webapps/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/workloads/2024-09-01/client.go b/resource-manager/workloads/2024-09-01/client.go new file mode 100644 index 00000000000..1721f61e63f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/client.go @@ -0,0 +1,55 @@ +package v2024_09_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapapplicationserverinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapcentralserverinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapdatabaseinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + SAPApplicationServerInstances *sapapplicationserverinstances.SAPApplicationServerInstancesClient + SAPCentralServerInstances *sapcentralserverinstances.SAPCentralServerInstancesClient + SAPDatabaseInstances *sapdatabaseinstances.SAPDatabaseInstancesClient + SAPVirtualInstances *sapvirtualinstances.SAPVirtualInstancesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + sAPApplicationServerInstancesClient, err := sapapplicationserverinstances.NewSAPApplicationServerInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPApplicationServerInstances client: %+v", err) + } + configureFunc(sAPApplicationServerInstancesClient.Client) + + sAPCentralServerInstancesClient, err := sapcentralserverinstances.NewSAPCentralServerInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPCentralServerInstances client: %+v", err) + } + configureFunc(sAPCentralServerInstancesClient.Client) + + sAPDatabaseInstancesClient, err := sapdatabaseinstances.NewSAPDatabaseInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPDatabaseInstances client: %+v", err) + } + configureFunc(sAPDatabaseInstancesClient.Client) + + sAPVirtualInstancesClient, err := sapvirtualinstances.NewSAPVirtualInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPVirtualInstances client: %+v", err) + } + configureFunc(sAPVirtualInstancesClient.Client) + + return &Client{ + SAPApplicationServerInstances: sAPApplicationServerInstancesClient, + SAPCentralServerInstances: sAPCentralServerInstancesClient, + SAPDatabaseInstances: sAPDatabaseInstancesClient, + SAPVirtualInstances: sAPVirtualInstancesClient, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md new file mode 100644 index 00000000000..465dbf93f8d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapapplicationserverinstances` Documentation + +The `sapapplicationserverinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapapplicationserverinstances" +``` + + +### Client Initialization + +```go +client := sapapplicationserverinstances.NewSAPApplicationServerInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.SAPApplicationServerInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +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: `SAPApplicationServerInstancesClient.List` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.UpdateSAPApplicationInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go new file mode 100644 index 00000000000..db488a14e78 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go @@ -0,0 +1,26 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPApplicationServerInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPApplicationServerInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapapplicationserverinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPApplicationServerInstancesClient: %+v", err) + } + + return &SAPApplicationServerInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go new file mode 100644 index 00000000000..d8b974d4109 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go @@ -0,0 +1,210 @@ +package sapapplicationserverinstances + +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 ApplicationServerVirtualMachineType string + +const ( + ApplicationServerVirtualMachineTypeActive ApplicationServerVirtualMachineType = "Active" + ApplicationServerVirtualMachineTypeStandby ApplicationServerVirtualMachineType = "Standby" + ApplicationServerVirtualMachineTypeUnknown ApplicationServerVirtualMachineType = "Unknown" +) + +func PossibleValuesForApplicationServerVirtualMachineType() []string { + return []string{ + string(ApplicationServerVirtualMachineTypeActive), + string(ApplicationServerVirtualMachineTypeStandby), + string(ApplicationServerVirtualMachineTypeUnknown), + } +} + +func (s *ApplicationServerVirtualMachineType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationServerVirtualMachineType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationServerVirtualMachineType(input string) (*ApplicationServerVirtualMachineType, error) { + vals := map[string]ApplicationServerVirtualMachineType{ + "active": ApplicationServerVirtualMachineTypeActive, + "standby": ApplicationServerVirtualMachineTypeStandby, + "unknown": ApplicationServerVirtualMachineTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationServerVirtualMachineType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go new file mode 100644 index 00000000000..3f2e13be454 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go @@ -0,0 +1,139 @@ +package sapapplicationserverinstances + +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(&ApplicationInstanceId{}) +} + +var _ resourceids.ResourceId = &ApplicationInstanceId{} + +// ApplicationInstanceId is a struct representing the Resource ID for a Application Instance +type ApplicationInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + ApplicationInstanceName string +} + +// NewApplicationInstanceID returns a new ApplicationInstanceId struct +func NewApplicationInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, applicationInstanceName string) ApplicationInstanceId { + return ApplicationInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + ApplicationInstanceName: applicationInstanceName, + } +} + +// ParseApplicationInstanceID parses 'input' into a ApplicationInstanceId +func ParseApplicationInstanceID(input string) (*ApplicationInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationInstanceIDInsensitively parses 'input' case-insensitively into a ApplicationInstanceId +// note: this method should only be used for API response data and not user input +func ParseApplicationInstanceIDInsensitively(input string) (*ApplicationInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.ApplicationInstanceName, ok = input.Parsed["applicationInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationInstanceName", input) + } + + return nil +} + +// ValidateApplicationInstanceID checks that 'input' can be parsed as a Application Instance ID +func ValidateApplicationInstanceID(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 := ParseApplicationInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Instance ID +func (id ApplicationInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/applicationInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.ApplicationInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Instance ID +func (id ApplicationInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticApplicationInstances", "applicationInstances", "applicationInstances"), + resourceids.UserSpecifiedSegment("applicationInstanceName", "applicationInstanceName"), + } +} + +// String returns a human-readable description of this Application Instance ID +func (id ApplicationInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Application Instance Name: %q", id.ApplicationInstanceName), + } + return fmt.Sprintf("Application Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go new file mode 100644 index 00000000000..4fa45a598af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go @@ -0,0 +1,327 @@ +package sapapplicationserverinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationInstanceId{} + +func TestNewApplicationInstanceID(t *testing.T) { + id := NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.ApplicationInstanceName != "applicationInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationInstanceName'", id.ApplicationInstanceName, "applicationInstanceName") + } +} + +func TestFormatApplicationInstanceID(t *testing.T) { + actual := NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + ApplicationInstanceName: "applicationInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.ApplicationInstanceName != v.Expected.ApplicationInstanceName { + t.Fatalf("Expected %q but got %q for ApplicationInstanceName", v.Expected.ApplicationInstanceName, actual.ApplicationInstanceName) + } + + } +} + +func TestParseApplicationInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + ApplicationInstanceName: "applicationInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS/aPpLiCaTiOnInStAnCeNaMe", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + ApplicationInstanceName: "aPpLiCaTiOnInStAnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS/aPpLiCaTiOnInStAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.ApplicationInstanceName != v.Expected.ApplicationInstanceName { + t.Fatalf("Expected %q but got %q for ApplicationInstanceName", v.Expected.ApplicationInstanceName, actual.ApplicationInstanceName) + } + + } +} + +func TestSegmentsForApplicationInstanceId(t *testing.T) { + segments := ApplicationInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..5c188729bb2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapapplicationserverinstances + +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(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..9b2455837f7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapapplicationserverinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go new file mode 100644 index 00000000000..ab1f8b5ee76 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPApplicationServerInstance +} + +// Create ... +func (c SAPApplicationServerInstancesClient) Create(ctx context.Context, id ApplicationInstanceId, input SAPApplicationServerInstance) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPApplicationServerInstancesClient) CreateThenPoll(ctx context.Context, id ApplicationInstanceId, input SAPApplicationServerInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go new file mode 100644 index 00000000000..ef31f64cc32 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstancesClient) Delete(ctx context.Context, id ApplicationInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 SAPApplicationServerInstancesClient) DeleteThenPoll(ctx context.Context, id ApplicationInstanceId) 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/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go new file mode 100644 index 00000000000..85535b6b205 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go @@ -0,0 +1,53 @@ +package sapapplicationserverinstances + +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 *SAPApplicationServerInstance +} + +// Get ... +func (c SAPApplicationServerInstancesClient) Get(ctx context.Context, id ApplicationInstanceId) (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 SAPApplicationServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go new file mode 100644 index 00000000000..e91a1644df2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go @@ -0,0 +1,105 @@ +package sapapplicationserverinstances + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPApplicationServerInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPApplicationServerInstance +} + +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 SAPApplicationServerInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/applicationInstances", 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 *[]SAPApplicationServerInstance `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 SAPApplicationServerInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPApplicationServerInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPApplicationServerInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPApplicationServerInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPApplicationServerInstance, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go new file mode 100644 index 00000000000..0545e8c99eb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPApplicationServerInstancesClient) Start(ctx context.Context, id ApplicationInstanceId, input StartRequest) (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 + } + + 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPApplicationServerInstancesClient) StartThenPoll(ctx context.Context, id ApplicationInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go new file mode 100644 index 00000000000..e572880ab74 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPApplicationServerInstancesClient) Stop(ctx context.Context, id ApplicationInstanceId, input StopRequest) (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 + } + + 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPApplicationServerInstancesClient) StopThenPoll(ctx context.Context, id ApplicationInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go new file mode 100644 index 00000000000..d1e46dcbf2e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go @@ -0,0 +1,57 @@ +package sapapplicationserverinstances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPApplicationServerInstance +} + +// Update ... +func (c SAPApplicationServerInstancesClient) Update(ctx context.Context, id ApplicationInstanceId, input UpdateSAPApplicationInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SAPApplicationServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go new file mode 100644 index 00000000000..b726103087c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerVMDetails struct { + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + Type *ApplicationServerVirtualMachineType `json:"type,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..0e481e26494 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go new file mode 100644 index 00000000000..46aaa86d6cc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go new file mode 100644 index 00000000000..1c96d28f14e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..3ff21a98118 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..ef30a3b1ed0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapapplicationserverinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go new file mode 100644 index 00000000000..a3837fdd73d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go @@ -0,0 +1,18 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPApplicationServerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go new file mode 100644 index 00000000000..d479c8bf7a7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go @@ -0,0 +1,23 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPApplicationServerProperties struct { + DispatcherStatus *string `json:"dispatcherStatus,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + GatewayPort *int64 `json:"gatewayPort,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IcmHTTPPort *int64 `json:"icmHttpPort,omitempty"` + IcmHTTPSPort *int64 `json:"icmHttpsPort,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]ApplicationServerVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..079f2c6a94d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go new file mode 100644 index 00000000000..4e9512a739f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go new file mode 100644 index 00000000000..603321b88ea --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go new file mode 100644 index 00000000000..c4b5853f8d7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go new file mode 100644 index 00000000000..47841304c98 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPApplicationInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go new file mode 100644 index 00000000000..29caee9a23c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go @@ -0,0 +1,32 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPApplicationServerInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPApplicationServerInstanceOperationPredicate) Matches(input SAPApplicationServerInstance) 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/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go new file mode 100644 index 00000000000..45916d1a57c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapapplicationserverinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md new file mode 100644 index 00000000000..41d59c38318 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapcentralserverinstances` Documentation + +The `sapcentralserverinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapcentralserverinstances" +``` + + +### Client Initialization + +```go +client := sapcentralserverinstances.NewSAPCentralServerInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.SAPCentralServerInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +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: `SAPCentralServerInstancesClient.List` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.UpdateSAPCentralInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go new file mode 100644 index 00000000000..3afe84dd512 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go @@ -0,0 +1,26 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPCentralServerInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPCentralServerInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapcentralserverinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPCentralServerInstancesClient: %+v", err) + } + + return &SAPCentralServerInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go new file mode 100644 index 00000000000..5123e35af40 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go @@ -0,0 +1,263 @@ +package sapcentralserverinstances + +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 CentralServerVirtualMachineType string + +const ( + CentralServerVirtualMachineTypeASCS CentralServerVirtualMachineType = "ASCS" + CentralServerVirtualMachineTypeERS CentralServerVirtualMachineType = "ERS" + CentralServerVirtualMachineTypeERSInactive CentralServerVirtualMachineType = "ERSInactive" + CentralServerVirtualMachineTypePrimary CentralServerVirtualMachineType = "Primary" + CentralServerVirtualMachineTypeSecondary CentralServerVirtualMachineType = "Secondary" + CentralServerVirtualMachineTypeStandby CentralServerVirtualMachineType = "Standby" + CentralServerVirtualMachineTypeUnknown CentralServerVirtualMachineType = "Unknown" +) + +func PossibleValuesForCentralServerVirtualMachineType() []string { + return []string{ + string(CentralServerVirtualMachineTypeASCS), + string(CentralServerVirtualMachineTypeERS), + string(CentralServerVirtualMachineTypeERSInactive), + string(CentralServerVirtualMachineTypePrimary), + string(CentralServerVirtualMachineTypeSecondary), + string(CentralServerVirtualMachineTypeStandby), + string(CentralServerVirtualMachineTypeUnknown), + } +} + +func (s *CentralServerVirtualMachineType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCentralServerVirtualMachineType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCentralServerVirtualMachineType(input string) (*CentralServerVirtualMachineType, error) { + vals := map[string]CentralServerVirtualMachineType{ + "ascs": CentralServerVirtualMachineTypeASCS, + "ers": CentralServerVirtualMachineTypeERS, + "ersinactive": CentralServerVirtualMachineTypeERSInactive, + "primary": CentralServerVirtualMachineTypePrimary, + "secondary": CentralServerVirtualMachineTypeSecondary, + "standby": CentralServerVirtualMachineTypeStandby, + "unknown": CentralServerVirtualMachineTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CentralServerVirtualMachineType(input) + return &out, nil +} + +type EnqueueReplicationServerType string + +const ( + EnqueueReplicationServerTypeEnqueueReplicatorOne EnqueueReplicationServerType = "EnqueueReplicator1" + EnqueueReplicationServerTypeEnqueueReplicatorTwo EnqueueReplicationServerType = "EnqueueReplicator2" +) + +func PossibleValuesForEnqueueReplicationServerType() []string { + return []string{ + string(EnqueueReplicationServerTypeEnqueueReplicatorOne), + string(EnqueueReplicationServerTypeEnqueueReplicatorTwo), + } +} + +func (s *EnqueueReplicationServerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnqueueReplicationServerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnqueueReplicationServerType(input string) (*EnqueueReplicationServerType, error) { + vals := map[string]EnqueueReplicationServerType{ + "enqueuereplicator1": EnqueueReplicationServerTypeEnqueueReplicatorOne, + "enqueuereplicator2": EnqueueReplicationServerTypeEnqueueReplicatorTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnqueueReplicationServerType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go new file mode 100644 index 00000000000..f1dc113cecf --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go @@ -0,0 +1,139 @@ +package sapcentralserverinstances + +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(&CentralInstanceId{}) +} + +var _ resourceids.ResourceId = &CentralInstanceId{} + +// CentralInstanceId is a struct representing the Resource ID for a Central Instance +type CentralInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + CentralInstanceName string +} + +// NewCentralInstanceID returns a new CentralInstanceId struct +func NewCentralInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, centralInstanceName string) CentralInstanceId { + return CentralInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + CentralInstanceName: centralInstanceName, + } +} + +// ParseCentralInstanceID parses 'input' into a CentralInstanceId +func ParseCentralInstanceID(input string) (*CentralInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CentralInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CentralInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCentralInstanceIDInsensitively parses 'input' case-insensitively into a CentralInstanceId +// note: this method should only be used for API response data and not user input +func ParseCentralInstanceIDInsensitively(input string) (*CentralInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CentralInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CentralInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CentralInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.CentralInstanceName, ok = input.Parsed["centralInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "centralInstanceName", input) + } + + return nil +} + +// ValidateCentralInstanceID checks that 'input' can be parsed as a Central Instance ID +func ValidateCentralInstanceID(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 := ParseCentralInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Central Instance ID +func (id CentralInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/centralInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.CentralInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Central Instance ID +func (id CentralInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticCentralInstances", "centralInstances", "centralInstances"), + resourceids.UserSpecifiedSegment("centralInstanceName", "centralInstanceName"), + } +} + +// String returns a human-readable description of this Central Instance ID +func (id CentralInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Central Instance Name: %q", id.CentralInstanceName), + } + return fmt.Sprintf("Central Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go new file mode 100644 index 00000000000..ef54149a599 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go @@ -0,0 +1,327 @@ +package sapcentralserverinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CentralInstanceId{} + +func TestNewCentralInstanceID(t *testing.T) { + id := NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.CentralInstanceName != "centralInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'CentralInstanceName'", id.CentralInstanceName, "centralInstanceName") + } +} + +func TestFormatCentralInstanceID(t *testing.T) { + actual := NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCentralInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CentralInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + CentralInstanceName: "centralInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCentralInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.CentralInstanceName != v.Expected.CentralInstanceName { + t.Fatalf("Expected %q but got %q for CentralInstanceName", v.Expected.CentralInstanceName, actual.CentralInstanceName) + } + + } +} + +func TestParseCentralInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CentralInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + CentralInstanceName: "centralInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS/cEnTrAlInStAnCeNaMe", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + CentralInstanceName: "cEnTrAlInStAnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS/cEnTrAlInStAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCentralInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.CentralInstanceName != v.Expected.CentralInstanceName { + t.Fatalf("Expected %q but got %q for CentralInstanceName", v.Expected.CentralInstanceName, actual.CentralInstanceName) + } + + } +} + +func TestSegmentsForCentralInstanceId(t *testing.T) { + segments := CentralInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CentralInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..8f987ad996b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapcentralserverinstances + +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(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..030e8ee55dd --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapcentralserverinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go new file mode 100644 index 00000000000..573c95e929e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPCentralServerInstance +} + +// Create ... +func (c SAPCentralServerInstancesClient) Create(ctx context.Context, id CentralInstanceId, input SAPCentralServerInstance) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPCentralServerInstancesClient) CreateThenPoll(ctx context.Context, id CentralInstanceId, input SAPCentralServerInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go new file mode 100644 index 00000000000..923f154846a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstancesClient) Delete(ctx context.Context, id CentralInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 SAPCentralServerInstancesClient) DeleteThenPoll(ctx context.Context, id CentralInstanceId) 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/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go new file mode 100644 index 00000000000..3d60cfb8ddc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go @@ -0,0 +1,53 @@ +package sapcentralserverinstances + +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 *SAPCentralServerInstance +} + +// Get ... +func (c SAPCentralServerInstancesClient) Get(ctx context.Context, id CentralInstanceId) (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 SAPCentralServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go new file mode 100644 index 00000000000..84fb920ff22 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go @@ -0,0 +1,105 @@ +package sapcentralserverinstances + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPCentralServerInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPCentralServerInstance +} + +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 SAPCentralServerInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/centralInstances", 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 *[]SAPCentralServerInstance `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 SAPCentralServerInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPCentralServerInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPCentralServerInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPCentralServerInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPCentralServerInstance, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go new file mode 100644 index 00000000000..f43ae42b616 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPCentralServerInstancesClient) Start(ctx context.Context, id CentralInstanceId, input StartRequest) (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 + } + + 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPCentralServerInstancesClient) StartThenPoll(ctx context.Context, id CentralInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go new file mode 100644 index 00000000000..3d90866c7af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPCentralServerInstancesClient) Stop(ctx context.Context, id CentralInstanceId, input StopRequest) (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 + } + + 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPCentralServerInstancesClient) StopThenPoll(ctx context.Context, id CentralInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go new file mode 100644 index 00000000000..0d38bae0695 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go @@ -0,0 +1,57 @@ +package sapcentralserverinstances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPCentralServerInstance +} + +// Update ... +func (c SAPCentralServerInstancesClient) Update(ctx context.Context, id CentralInstanceId, input UpdateSAPCentralInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SAPCentralServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go new file mode 100644 index 00000000000..51e66ae4628 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerVMDetails struct { + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + Type *CentralServerVirtualMachineType `json:"type,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go new file mode 100644 index 00000000000..c8bdb57a883 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go @@ -0,0 +1,14 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnqueueReplicationServerProperties struct { + ErsVersion *EnqueueReplicationServerType `json:"ersVersion,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go new file mode 100644 index 00000000000..8f338c92243 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go @@ -0,0 +1,11 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnqueueServerProperties struct { + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..da146f1761c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go new file mode 100644 index 00000000000..1e2bc5a1a72 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go new file mode 100644 index 00000000000..2602ea3533b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go new file mode 100644 index 00000000000..603e6e7577d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayServerProperties struct { + Health *SAPHealthState `json:"health,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..3907ef35a43 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go new file mode 100644 index 00000000000..fe1c784bb49 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go @@ -0,0 +1,14 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageServerProperties struct { + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InternalMsPort *int64 `json:"internalMsPort,omitempty"` + MsPort *int64 `json:"msPort,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..2aa75ea1f54 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapcentralserverinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go new file mode 100644 index 00000000000..95b8cbc088c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go @@ -0,0 +1,18 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPCentralServerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go new file mode 100644 index 00000000000..7a0dd2ab42a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go @@ -0,0 +1,21 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPCentralServerProperties struct { + EnqueueReplicationServerProperties *EnqueueReplicationServerProperties `json:"enqueueReplicationServerProperties,omitempty"` + EnqueueServerProperties *EnqueueServerProperties `json:"enqueueServerProperties,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + GatewayServerProperties *GatewayServerProperties `json:"gatewayServerProperties,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + MessageServerProperties *MessageServerProperties `json:"messageServerProperties,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]CentralServerVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..dc2d54ce4ae --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go new file mode 100644 index 00000000000..ff3ed0c7bcb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go new file mode 100644 index 00000000000..bff0289b502 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go new file mode 100644 index 00000000000..fe88f2d14c1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go new file mode 100644 index 00000000000..f22c45eeaf7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPCentralInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go new file mode 100644 index 00000000000..425219f1f39 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go @@ -0,0 +1,32 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPCentralServerInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPCentralServerInstanceOperationPredicate) Matches(input SAPCentralServerInstance) 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/resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go new file mode 100644 index 00000000000..50ae7a3b83e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapcentralserverinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md new file mode 100644 index 00000000000..4178575ceaa --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapdatabaseinstances` Documentation + +The `sapdatabaseinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapdatabaseinstances" +``` + + +### Client Initialization + +```go +client := sapdatabaseinstances.NewSAPDatabaseInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.SAPDatabaseInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +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: `SAPDatabaseInstancesClient.List` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.UpdateSAPDatabaseInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go new file mode 100644 index 00000000000..7ef60c6a773 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go @@ -0,0 +1,26 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPDatabaseInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPDatabaseInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapdatabaseinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPDatabaseInstancesClient: %+v", err) + } + + return &SAPDatabaseInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go new file mode 100644 index 00000000000..242c9049980 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go @@ -0,0 +1,119 @@ +package sapdatabaseinstances + +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 SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go new file mode 100644 index 00000000000..7b114164c04 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go @@ -0,0 +1,139 @@ +package sapdatabaseinstances + +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(&DatabaseInstanceId{}) +} + +var _ resourceids.ResourceId = &DatabaseInstanceId{} + +// DatabaseInstanceId is a struct representing the Resource ID for a Database Instance +type DatabaseInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + DatabaseInstanceName string +} + +// NewDatabaseInstanceID returns a new DatabaseInstanceId struct +func NewDatabaseInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, databaseInstanceName string) DatabaseInstanceId { + return DatabaseInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + DatabaseInstanceName: databaseInstanceName, + } +} + +// ParseDatabaseInstanceID parses 'input' into a DatabaseInstanceId +func ParseDatabaseInstanceID(input string) (*DatabaseInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseInstanceIDInsensitively parses 'input' case-insensitively into a DatabaseInstanceId +// note: this method should only be used for API response data and not user input +func ParseDatabaseInstanceIDInsensitively(input string) (*DatabaseInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.DatabaseInstanceName, ok = input.Parsed["databaseInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseInstanceName", input) + } + + return nil +} + +// ValidateDatabaseInstanceID checks that 'input' can be parsed as a Database Instance ID +func ValidateDatabaseInstanceID(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 := ParseDatabaseInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Instance ID +func (id DatabaseInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/databaseInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.DatabaseInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Instance ID +func (id DatabaseInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticDatabaseInstances", "databaseInstances", "databaseInstances"), + resourceids.UserSpecifiedSegment("databaseInstanceName", "databaseInstanceName"), + } +} + +// String returns a human-readable description of this Database Instance ID +func (id DatabaseInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Database Instance Name: %q", id.DatabaseInstanceName), + } + return fmt.Sprintf("Database Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go new file mode 100644 index 00000000000..9ac9a5f54c9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go @@ -0,0 +1,327 @@ +package sapdatabaseinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DatabaseInstanceId{} + +func TestNewDatabaseInstanceID(t *testing.T) { + id := NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.DatabaseInstanceName != "databaseInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseInstanceName'", id.DatabaseInstanceName, "databaseInstanceName") + } +} + +func TestFormatDatabaseInstanceID(t *testing.T) { + actual := NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + DatabaseInstanceName: "databaseInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.DatabaseInstanceName != v.Expected.DatabaseInstanceName { + t.Fatalf("Expected %q but got %q for DatabaseInstanceName", v.Expected.DatabaseInstanceName, actual.DatabaseInstanceName) + } + + } +} + +func TestParseDatabaseInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + DatabaseInstanceName: "databaseInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs/dAtAbAsEiNsTaNcEnAmE", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + DatabaseInstanceName: "dAtAbAsEiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs/dAtAbAsEiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.DatabaseInstanceName != v.Expected.DatabaseInstanceName { + t.Fatalf("Expected %q but got %q for DatabaseInstanceName", v.Expected.DatabaseInstanceName, actual.DatabaseInstanceName) + } + + } +} + +func TestSegmentsForDatabaseInstanceId(t *testing.T) { + segments := DatabaseInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..f4f8aa9d143 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapdatabaseinstances + +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(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..0a5881b6428 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapdatabaseinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go new file mode 100644 index 00000000000..7317badba24 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPDatabaseInstance +} + +// Create ... +func (c SAPDatabaseInstancesClient) Create(ctx context.Context, id DatabaseInstanceId, input SAPDatabaseInstance) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPDatabaseInstancesClient) CreateThenPoll(ctx context.Context, id DatabaseInstanceId, input SAPDatabaseInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go new file mode 100644 index 00000000000..87d7e580a3a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstancesClient) Delete(ctx context.Context, id DatabaseInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 SAPDatabaseInstancesClient) DeleteThenPoll(ctx context.Context, id DatabaseInstanceId) 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/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go new file mode 100644 index 00000000000..1c4add58a17 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go @@ -0,0 +1,53 @@ +package sapdatabaseinstances + +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 *SAPDatabaseInstance +} + +// Get ... +func (c SAPDatabaseInstancesClient) Get(ctx context.Context, id DatabaseInstanceId) (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 SAPDatabaseInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go new file mode 100644 index 00000000000..ce164baa7f1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go @@ -0,0 +1,105 @@ +package sapdatabaseinstances + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPDatabaseInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPDatabaseInstance +} + +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 SAPDatabaseInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/databaseInstances", 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 *[]SAPDatabaseInstance `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 SAPDatabaseInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPDatabaseInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPDatabaseInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPDatabaseInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPDatabaseInstance, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go new file mode 100644 index 00000000000..0202a996a2c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPDatabaseInstancesClient) Start(ctx context.Context, id DatabaseInstanceId, input StartRequest) (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 + } + + 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPDatabaseInstancesClient) StartThenPoll(ctx context.Context, id DatabaseInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go new file mode 100644 index 00000000000..a4696981eee --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPDatabaseInstancesClient) Stop(ctx context.Context, id DatabaseInstanceId, input StopRequest) (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 + } + + 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPDatabaseInstancesClient) StopThenPoll(ctx context.Context, id DatabaseInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go new file mode 100644 index 00000000000..eafa8168fd9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go @@ -0,0 +1,57 @@ +package sapdatabaseinstances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPDatabaseInstance +} + +// Update ... +func (c SAPDatabaseInstancesClient) Update(ctx context.Context, id DatabaseInstanceId, input UpdateSAPDatabaseInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SAPDatabaseInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go new file mode 100644 index 00000000000..61f23878c82 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseVMDetails struct { + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..3f0ca0f13ad --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go new file mode 100644 index 00000000000..a0010440822 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go new file mode 100644 index 00000000000..109ec8b6f46 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..c13208cd34a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..f6e093ddffd --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapdatabaseinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go new file mode 100644 index 00000000000..04f0b39f6d3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go @@ -0,0 +1,18 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPDatabaseProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go new file mode 100644 index 00000000000..25dd497a869 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go @@ -0,0 +1,16 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDatabaseProperties struct { + DatabaseSid *string `json:"databaseSid,omitempty"` + DatabaseType *string `json:"databaseType,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]DatabaseVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..016147f0493 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go new file mode 100644 index 00000000000..59064628a09 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go new file mode 100644 index 00000000000..34a89b63370 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go new file mode 100644 index 00000000000..4f5182e83c0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go new file mode 100644 index 00000000000..31957d5bbca --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPDatabaseInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go new file mode 100644 index 00000000000..eba9c19b470 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go @@ -0,0 +1,32 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDatabaseInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPDatabaseInstanceOperationPredicate) Matches(input SAPDatabaseInstance) 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/resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go new file mode 100644 index 00000000000..7d4dd3d65f9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapdatabaseinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md b/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md new file mode 100644 index 00000000000..44ad2680008 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md @@ -0,0 +1,235 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances` Documentation + +The `sapvirtualinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances" +``` + + +### Client Initialization + +```go +client := sapvirtualinstances.NewSAPVirtualInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPVirtualInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.SAPVirtualInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +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: `SAPVirtualInstancesClient.InvokeAvailabilityZoneDetails` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPAvailabilityZoneDetailsRequest{ + // ... +} + + +read, err := client.InvokeAvailabilityZoneDetails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeDiskConfigurations` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPDiskConfigurationsRequest{ + // ... +} + + +read, err := client.InvokeDiskConfigurations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeSapSupportedSku` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPSupportedSkusRequest{ + // ... +} + + +read, err := client.InvokeSapSupportedSku(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeSizingRecommendations` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPSizingRecommendationRequest{ + // ... +} + + +read, err := client.InvokeSizingRecommendations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.UpdateSAPVirtualInstanceRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go new file mode 100644 index 00000000000..e7297735c3f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go @@ -0,0 +1,26 @@ +package sapvirtualinstances + +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 SAPVirtualInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPVirtualInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPVirtualInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapvirtualinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPVirtualInstancesClient: %+v", err) + } + + return &SAPVirtualInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go new file mode 100644 index 00000000000..b67571e0654 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go @@ -0,0 +1,794 @@ +package sapvirtualinstances + +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 DiskSkuName string + +const ( + DiskSkuNamePremiumLRS DiskSkuName = "Premium_LRS" + DiskSkuNamePremiumVTwoLRS DiskSkuName = "PremiumV2_LRS" + DiskSkuNamePremiumZRS DiskSkuName = "Premium_ZRS" + DiskSkuNameStandardLRS DiskSkuName = "Standard_LRS" + DiskSkuNameStandardSSDLRS DiskSkuName = "StandardSSD_LRS" + DiskSkuNameStandardSSDZRS DiskSkuName = "StandardSSD_ZRS" + DiskSkuNameUltraSSDLRS DiskSkuName = "UltraSSD_LRS" +) + +func PossibleValuesForDiskSkuName() []string { + return []string{ + string(DiskSkuNamePremiumLRS), + string(DiskSkuNamePremiumVTwoLRS), + string(DiskSkuNamePremiumZRS), + string(DiskSkuNameStandardLRS), + string(DiskSkuNameStandardSSDLRS), + string(DiskSkuNameStandardSSDZRS), + string(DiskSkuNameUltraSSDLRS), + } +} + +func (s *DiskSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskSkuName(input string) (*DiskSkuName, error) { + vals := map[string]DiskSkuName{ + "premium_lrs": DiskSkuNamePremiumLRS, + "premiumv2_lrs": DiskSkuNamePremiumVTwoLRS, + "premium_zrs": DiskSkuNamePremiumZRS, + "standard_lrs": DiskSkuNameStandardLRS, + "standardssd_lrs": DiskSkuNameStandardSSDLRS, + "standardssd_zrs": DiskSkuNameStandardSSDZRS, + "ultrassd_lrs": DiskSkuNameUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskSkuName(input) + return &out, nil +} + +type FileShareConfigurationType string + +const ( + FileShareConfigurationTypeCreateAndMount FileShareConfigurationType = "CreateAndMount" + FileShareConfigurationTypeMount FileShareConfigurationType = "Mount" + FileShareConfigurationTypeSkip FileShareConfigurationType = "Skip" +) + +func PossibleValuesForFileShareConfigurationType() []string { + return []string{ + string(FileShareConfigurationTypeCreateAndMount), + string(FileShareConfigurationTypeMount), + string(FileShareConfigurationTypeSkip), + } +} + +func (s *FileShareConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFileShareConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFileShareConfigurationType(input string) (*FileShareConfigurationType, error) { + vals := map[string]FileShareConfigurationType{ + "createandmount": FileShareConfigurationTypeCreateAndMount, + "mount": FileShareConfigurationTypeMount, + "skip": FileShareConfigurationTypeSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileShareConfigurationType(input) + return &out, nil +} + +type ManagedResourcesNetworkAccessType string + +const ( + ManagedResourcesNetworkAccessTypePrivate ManagedResourcesNetworkAccessType = "Private" + ManagedResourcesNetworkAccessTypePublic ManagedResourcesNetworkAccessType = "Public" +) + +func PossibleValuesForManagedResourcesNetworkAccessType() []string { + return []string{ + string(ManagedResourcesNetworkAccessTypePrivate), + string(ManagedResourcesNetworkAccessTypePublic), + } +} + +func (s *ManagedResourcesNetworkAccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourcesNetworkAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedResourcesNetworkAccessType(input string) (*ManagedResourcesNetworkAccessType, error) { + vals := map[string]ManagedResourcesNetworkAccessType{ + "private": ManagedResourcesNetworkAccessTypePrivate, + "public": ManagedResourcesNetworkAccessTypePublic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedResourcesNetworkAccessType(input) + return &out, nil +} + +type NamingPatternType string + +const ( + NamingPatternTypeFullResourceName NamingPatternType = "FullResourceName" +) + +func PossibleValuesForNamingPatternType() []string { + return []string{ + string(NamingPatternTypeFullResourceName), + } +} + +func (s *NamingPatternType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNamingPatternType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNamingPatternType(input string) (*NamingPatternType, error) { + vals := map[string]NamingPatternType{ + "fullresourcename": NamingPatternTypeFullResourceName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NamingPatternType(input) + return &out, nil +} + +type OSType string + +const ( + OSTypeLinux OSType = "Linux" + OSTypeWindows OSType = "Windows" +) + +func PossibleValuesForOSType() []string { + return []string{ + string(OSTypeLinux), + string(OSTypeWindows), + } +} + +func (s *OSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSType(input string) (*OSType, error) { + vals := map[string]OSType{ + "linux": OSTypeLinux, + "windows": OSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSType(input) + return &out, nil +} + +type SAPConfigurationType string + +const ( + SAPConfigurationTypeDeployment SAPConfigurationType = "Deployment" + SAPConfigurationTypeDeploymentWithOSConfig SAPConfigurationType = "DeploymentWithOSConfig" + SAPConfigurationTypeDiscovery SAPConfigurationType = "Discovery" +) + +func PossibleValuesForSAPConfigurationType() []string { + return []string{ + string(SAPConfigurationTypeDeployment), + string(SAPConfigurationTypeDeploymentWithOSConfig), + string(SAPConfigurationTypeDiscovery), + } +} + +func (s *SAPConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPConfigurationType(input string) (*SAPConfigurationType, error) { + vals := map[string]SAPConfigurationType{ + "deployment": SAPConfigurationTypeDeployment, + "deploymentwithosconfig": SAPConfigurationTypeDeploymentWithOSConfig, + "discovery": SAPConfigurationTypeDiscovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPConfigurationType(input) + return &out, nil +} + +type SAPDatabaseScaleMethod string + +const ( + SAPDatabaseScaleMethodScaleUp SAPDatabaseScaleMethod = "ScaleUp" +) + +func PossibleValuesForSAPDatabaseScaleMethod() []string { + return []string{ + string(SAPDatabaseScaleMethodScaleUp), + } +} + +func (s *SAPDatabaseScaleMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDatabaseScaleMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDatabaseScaleMethod(input string) (*SAPDatabaseScaleMethod, error) { + vals := map[string]SAPDatabaseScaleMethod{ + "scaleup": SAPDatabaseScaleMethodScaleUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDatabaseScaleMethod(input) + return &out, nil +} + +type SAPDatabaseType string + +const ( + SAPDatabaseTypeDBTwo SAPDatabaseType = "DB2" + SAPDatabaseTypeHANA SAPDatabaseType = "HANA" +) + +func PossibleValuesForSAPDatabaseType() []string { + return []string{ + string(SAPDatabaseTypeDBTwo), + string(SAPDatabaseTypeHANA), + } +} + +func (s *SAPDatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDatabaseType(input string) (*SAPDatabaseType, error) { + vals := map[string]SAPDatabaseType{ + "db2": SAPDatabaseTypeDBTwo, + "hana": SAPDatabaseTypeHANA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDatabaseType(input) + return &out, nil +} + +type SAPDeploymentType string + +const ( + SAPDeploymentTypeSingleServer SAPDeploymentType = "SingleServer" + SAPDeploymentTypeThreeTier SAPDeploymentType = "ThreeTier" +) + +func PossibleValuesForSAPDeploymentType() []string { + return []string{ + string(SAPDeploymentTypeSingleServer), + string(SAPDeploymentTypeThreeTier), + } +} + +func (s *SAPDeploymentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDeploymentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDeploymentType(input string) (*SAPDeploymentType, error) { + vals := map[string]SAPDeploymentType{ + "singleserver": SAPDeploymentTypeSingleServer, + "threetier": SAPDeploymentTypeThreeTier, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDeploymentType(input) + return &out, nil +} + +type SAPEnvironmentType string + +const ( + SAPEnvironmentTypeNonProd SAPEnvironmentType = "NonProd" + SAPEnvironmentTypeProd SAPEnvironmentType = "Prod" +) + +func PossibleValuesForSAPEnvironmentType() []string { + return []string{ + string(SAPEnvironmentTypeNonProd), + string(SAPEnvironmentTypeProd), + } +} + +func (s *SAPEnvironmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPEnvironmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPEnvironmentType(input string) (*SAPEnvironmentType, error) { + vals := map[string]SAPEnvironmentType{ + "nonprod": SAPEnvironmentTypeNonProd, + "prod": SAPEnvironmentTypeProd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPEnvironmentType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPHighAvailabilityType string + +const ( + SAPHighAvailabilityTypeAvailabilitySet SAPHighAvailabilityType = "AvailabilitySet" + SAPHighAvailabilityTypeAvailabilityZone SAPHighAvailabilityType = "AvailabilityZone" +) + +func PossibleValuesForSAPHighAvailabilityType() []string { + return []string{ + string(SAPHighAvailabilityTypeAvailabilitySet), + string(SAPHighAvailabilityTypeAvailabilityZone), + } +} + +func (s *SAPHighAvailabilityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHighAvailabilityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHighAvailabilityType(input string) (*SAPHighAvailabilityType, error) { + vals := map[string]SAPHighAvailabilityType{ + "availabilityset": SAPHighAvailabilityTypeAvailabilitySet, + "availabilityzone": SAPHighAvailabilityTypeAvailabilityZone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHighAvailabilityType(input) + return &out, nil +} + +type SAPProductType string + +const ( + SAPProductTypeECC SAPProductType = "ECC" + SAPProductTypeOther SAPProductType = "Other" + SAPProductTypeSFourHANA SAPProductType = "S4HANA" +) + +func PossibleValuesForSAPProductType() []string { + return []string{ + string(SAPProductTypeECC), + string(SAPProductTypeOther), + string(SAPProductTypeSFourHANA), + } +} + +func (s *SAPProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPProductType(input string) (*SAPProductType, error) { + vals := map[string]SAPProductType{ + "ecc": SAPProductTypeECC, + "other": SAPProductTypeOther, + "s4hana": SAPProductTypeSFourHANA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPProductType(input) + return &out, nil +} + +type SAPSoftwareInstallationType string + +const ( + SAPSoftwareInstallationTypeExternal SAPSoftwareInstallationType = "External" + SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig SAPSoftwareInstallationType = "SAPInstallWithoutOSConfig" + SAPSoftwareInstallationTypeServiceInitiated SAPSoftwareInstallationType = "ServiceInitiated" +) + +func PossibleValuesForSAPSoftwareInstallationType() []string { + return []string{ + string(SAPSoftwareInstallationTypeExternal), + string(SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig), + string(SAPSoftwareInstallationTypeServiceInitiated), + } +} + +func (s *SAPSoftwareInstallationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPSoftwareInstallationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPSoftwareInstallationType(input string) (*SAPSoftwareInstallationType, error) { + vals := map[string]SAPSoftwareInstallationType{ + "external": SAPSoftwareInstallationTypeExternal, + "sapinstallwithoutosconfig": SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig, + "serviceinitiated": SAPSoftwareInstallationTypeServiceInitiated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPSoftwareInstallationType(input) + return &out, nil +} + +type SAPVirtualInstanceState string + +const ( + SAPVirtualInstanceStateACSSInstallationBlocked SAPVirtualInstanceState = "ACSSInstallationBlocked" + SAPVirtualInstanceStateDiscoveryFailed SAPVirtualInstanceState = "DiscoveryFailed" + SAPVirtualInstanceStateDiscoveryInProgress SAPVirtualInstanceState = "DiscoveryInProgress" + SAPVirtualInstanceStateDiscoveryPending SAPVirtualInstanceState = "DiscoveryPending" + SAPVirtualInstanceStateInfrastructureDeploymentFailed SAPVirtualInstanceState = "InfrastructureDeploymentFailed" + SAPVirtualInstanceStateInfrastructureDeploymentInProgress SAPVirtualInstanceState = "InfrastructureDeploymentInProgress" + SAPVirtualInstanceStateInfrastructureDeploymentPending SAPVirtualInstanceState = "InfrastructureDeploymentPending" + SAPVirtualInstanceStateRegistrationComplete SAPVirtualInstanceState = "RegistrationComplete" + SAPVirtualInstanceStateSoftwareDetectionFailed SAPVirtualInstanceState = "SoftwareDetectionFailed" + SAPVirtualInstanceStateSoftwareDetectionInProgress SAPVirtualInstanceState = "SoftwareDetectionInProgress" + SAPVirtualInstanceStateSoftwareInstallationFailed SAPVirtualInstanceState = "SoftwareInstallationFailed" + SAPVirtualInstanceStateSoftwareInstallationInProgress SAPVirtualInstanceState = "SoftwareInstallationInProgress" + SAPVirtualInstanceStateSoftwareInstallationPending SAPVirtualInstanceState = "SoftwareInstallationPending" +) + +func PossibleValuesForSAPVirtualInstanceState() []string { + return []string{ + string(SAPVirtualInstanceStateACSSInstallationBlocked), + string(SAPVirtualInstanceStateDiscoveryFailed), + string(SAPVirtualInstanceStateDiscoveryInProgress), + string(SAPVirtualInstanceStateDiscoveryPending), + string(SAPVirtualInstanceStateInfrastructureDeploymentFailed), + string(SAPVirtualInstanceStateInfrastructureDeploymentInProgress), + string(SAPVirtualInstanceStateInfrastructureDeploymentPending), + string(SAPVirtualInstanceStateRegistrationComplete), + string(SAPVirtualInstanceStateSoftwareDetectionFailed), + string(SAPVirtualInstanceStateSoftwareDetectionInProgress), + string(SAPVirtualInstanceStateSoftwareInstallationFailed), + string(SAPVirtualInstanceStateSoftwareInstallationInProgress), + string(SAPVirtualInstanceStateSoftwareInstallationPending), + } +} + +func (s *SAPVirtualInstanceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceState(input string) (*SAPVirtualInstanceState, error) { + vals := map[string]SAPVirtualInstanceState{ + "acssinstallationblocked": SAPVirtualInstanceStateACSSInstallationBlocked, + "discoveryfailed": SAPVirtualInstanceStateDiscoveryFailed, + "discoveryinprogress": SAPVirtualInstanceStateDiscoveryInProgress, + "discoverypending": SAPVirtualInstanceStateDiscoveryPending, + "infrastructuredeploymentfailed": SAPVirtualInstanceStateInfrastructureDeploymentFailed, + "infrastructuredeploymentinprogress": SAPVirtualInstanceStateInfrastructureDeploymentInProgress, + "infrastructuredeploymentpending": SAPVirtualInstanceStateInfrastructureDeploymentPending, + "registrationcomplete": SAPVirtualInstanceStateRegistrationComplete, + "softwaredetectionfailed": SAPVirtualInstanceStateSoftwareDetectionFailed, + "softwaredetectioninprogress": SAPVirtualInstanceStateSoftwareDetectionInProgress, + "softwareinstallationfailed": SAPVirtualInstanceStateSoftwareInstallationFailed, + "softwareinstallationinprogress": SAPVirtualInstanceStateSoftwareInstallationInProgress, + "softwareinstallationpending": SAPVirtualInstanceStateSoftwareInstallationPending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go new file mode 100644 index 00000000000..bff26be9c89 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go @@ -0,0 +1,121 @@ +package sapvirtualinstances + +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(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Workloads/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go new file mode 100644 index 00000000000..a693a81b998 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go @@ -0,0 +1,237 @@ +package sapvirtualinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..64a6c56e20c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapvirtualinstances + +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(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..6348f9430ac --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapvirtualinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go new file mode 100644 index 00000000000..cf665a1c878 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPVirtualInstance +} + +// Create ... +func (c SAPVirtualInstancesClient) Create(ctx context.Context, id SapVirtualInstanceId, input SAPVirtualInstance) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPVirtualInstancesClient) CreateThenPoll(ctx context.Context, id SapVirtualInstanceId, input SAPVirtualInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go new file mode 100644 index 00000000000..b945144f8af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapvirtualinstances + +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 SAPVirtualInstancesClient) Delete(ctx context.Context, id SapVirtualInstanceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 SAPVirtualInstancesClient) DeleteThenPoll(ctx context.Context, id SapVirtualInstanceId) 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/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go new file mode 100644 index 00000000000..a475bb7cdfb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +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 *SAPVirtualInstance +} + +// Get ... +func (c SAPVirtualInstancesClient) Get(ctx context.Context, id SapVirtualInstanceId) (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 SAPVirtualInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go new file mode 100644 index 00000000000..a392cd30743 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +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 InvokeAvailabilityZoneDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPAvailabilityZoneDetailsResult +} + +// InvokeAvailabilityZoneDetails ... +func (c SAPVirtualInstancesClient) InvokeAvailabilityZoneDetails(ctx context.Context, id LocationId, input SAPAvailabilityZoneDetailsRequest) (result InvokeAvailabilityZoneDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails", 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 SAPAvailabilityZoneDetailsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go new file mode 100644 index 00000000000..b76d7789f1b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +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 InvokeDiskConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPDiskConfigurationsResult +} + +// InvokeDiskConfigurations ... +func (c SAPVirtualInstancesClient) InvokeDiskConfigurations(ctx context.Context, id LocationId, input SAPDiskConfigurationsRequest) (result InvokeDiskConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getDiskConfigurations", 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 SAPDiskConfigurationsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go new file mode 100644 index 00000000000..94a2f51a83f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +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 InvokeSapSupportedSkuOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPSupportedResourceSkusResult +} + +// InvokeSapSupportedSku ... +func (c SAPVirtualInstancesClient) InvokeSapSupportedSku(ctx context.Context, id LocationId, input SAPSupportedSkusRequest) (result InvokeSapSupportedSkuOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getSapSupportedSku", 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 SAPSupportedResourceSkusResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go new file mode 100644 index 00000000000..df9142c7a11 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go @@ -0,0 +1,63 @@ +package sapvirtualinstances + +import ( + "context" + "encoding/json" + "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 InvokeSizingRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model SAPSizingRecommendationResult +} + +// InvokeSizingRecommendations ... +func (c SAPVirtualInstancesClient) InvokeSizingRecommendations(ctx context.Context, id LocationId, input SAPSizingRecommendationRequest) (result InvokeSizingRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getSizingRecommendations", 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 respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalSAPSizingRecommendationResultImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go new file mode 100644 index 00000000000..82e423c66ab --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package sapvirtualinstances + +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 *[]SAPVirtualInstance +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPVirtualInstance +} + +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 SAPVirtualInstancesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Workloads/sapVirtualInstances", 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 *[]SAPVirtualInstance `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 SAPVirtualInstancesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SAPVirtualInstanceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPVirtualInstancesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SAPVirtualInstanceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SAPVirtualInstance, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go new file mode 100644 index 00000000000..69718c73bd8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go @@ -0,0 +1,106 @@ +package sapvirtualinstances + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPVirtualInstance +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPVirtualInstance +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c SAPVirtualInstancesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Workloads/sapVirtualInstances", 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 *[]SAPVirtualInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SAPVirtualInstancesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SAPVirtualInstanceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPVirtualInstancesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SAPVirtualInstanceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SAPVirtualInstance, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go new file mode 100644 index 00000000000..b2814bb9cd5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPVirtualInstancesClient) Start(ctx context.Context, id SapVirtualInstanceId, input StartRequest) (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 + } + + 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPVirtualInstancesClient) StartThenPoll(ctx context.Context, id SapVirtualInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go new file mode 100644 index 00000000000..aac10878a2b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPVirtualInstancesClient) Stop(ctx context.Context, id SapVirtualInstanceId, input StopRequest) (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 + } + + 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPVirtualInstancesClient) StopThenPoll(ctx context.Context, id SapVirtualInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go new file mode 100644 index 00000000000..b3f22f61acb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPVirtualInstance +} + +// Update ... +func (c SAPVirtualInstancesClient) Update(ctx context.Context, id SapVirtualInstanceId, input UpdateSAPVirtualInstanceRequest) (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 SAPVirtualInstancesClient) UpdateThenPoll(ctx context.Context, id SapVirtualInstanceId, input UpdateSAPVirtualInstanceRequest) 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/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go new file mode 100644 index 00000000000..16e4d301f4c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerConfiguration struct { + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go new file mode 100644 index 00000000000..2b99b68a423 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go new file mode 100644 index 00000000000..691fffbf2c7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerConfiguration struct { + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go new file mode 100644 index 00000000000..c3a013c0f52 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + LoadBalancer *LoadBalancerResourceNames `json:"loadBalancer,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go new file mode 100644 index 00000000000..a3a5b08974c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go @@ -0,0 +1,51 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = CreateAndMountFileShareConfiguration{} + +type CreateAndMountFileShareConfiguration struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s CreateAndMountFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = CreateAndMountFileShareConfiguration{} + +func (s CreateAndMountFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper CreateAndMountFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "CreateAndMount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go new file mode 100644 index 00000000000..3777d01e9b8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConfiguration struct { + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DiskConfiguration *DiskConfiguration `json:"diskConfiguration,omitempty"` + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go new file mode 100644 index 00000000000..ee192d2c046 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + LoadBalancer *LoadBalancerResourceNames `json:"loadBalancer,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go new file mode 100644 index 00000000000..bfcd632981c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeployerVMPackages struct { + StorageAccountId *string `json:"storageAccountId,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go new file mode 100644 index 00000000000..f1c10fae8c3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go @@ -0,0 +1,90 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DeploymentConfiguration{} + +type DeploymentConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + InfrastructureConfiguration InfrastructureConfiguration `json:"infrastructureConfiguration"` + SoftwareConfiguration SoftwareConfiguration `json:"softwareConfiguration"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DeploymentConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DeploymentConfiguration{} + +func (s DeploymentConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DeploymentConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeploymentConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeploymentConfiguration: %+v", err) + } + + decoded["configurationType"] = "Deployment" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeploymentConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DeploymentConfiguration{} + +func (s *DeploymentConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppLocation *string `json:"appLocation,omitempty"` + ConfigurationType SAPConfigurationType `json:"configurationType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppLocation = decoded.AppLocation + s.ConfigurationType = decoded.ConfigurationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeploymentConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["infrastructureConfiguration"]; ok { + impl, err := UnmarshalInfrastructureConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'InfrastructureConfiguration' for 'DeploymentConfiguration': %+v", err) + } + s.InfrastructureConfiguration = impl + } + + if v, ok := temp["softwareConfiguration"]; ok { + impl, err := UnmarshalSoftwareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SoftwareConfiguration' for 'DeploymentConfiguration': %+v", err) + } + s.SoftwareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go new file mode 100644 index 00000000000..9feff2a8ee7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go @@ -0,0 +1,93 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DeploymentWithOSConfiguration{} + +type DeploymentWithOSConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + InfrastructureConfiguration InfrastructureConfiguration `json:"infrastructureConfiguration"` + OsSapConfiguration *OsSapConfiguration `json:"osSapConfiguration,omitempty"` + SoftwareConfiguration SoftwareConfiguration `json:"softwareConfiguration"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DeploymentWithOSConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DeploymentWithOSConfiguration{} + +func (s DeploymentWithOSConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DeploymentWithOSConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeploymentWithOSConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeploymentWithOSConfiguration: %+v", err) + } + + decoded["configurationType"] = "DeploymentWithOSConfig" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeploymentWithOSConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DeploymentWithOSConfiguration{} + +func (s *DeploymentWithOSConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppLocation *string `json:"appLocation,omitempty"` + OsSapConfiguration *OsSapConfiguration `json:"osSapConfiguration,omitempty"` + ConfigurationType SAPConfigurationType `json:"configurationType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppLocation = decoded.AppLocation + s.OsSapConfiguration = decoded.OsSapConfiguration + s.ConfigurationType = decoded.ConfigurationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeploymentWithOSConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["infrastructureConfiguration"]; ok { + impl, err := UnmarshalInfrastructureConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'InfrastructureConfiguration' for 'DeploymentWithOSConfiguration': %+v", err) + } + s.InfrastructureConfiguration = impl + } + + if v, ok := temp["softwareConfiguration"]; ok { + impl, err := UnmarshalSoftwareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SoftwareConfiguration' for 'DeploymentWithOSConfiguration': %+v", err) + } + s.SoftwareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go new file mode 100644 index 00000000000..05e6556d368 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go @@ -0,0 +1,52 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DiscoveryConfiguration{} + +type DiscoveryConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + CentralServerVMId *string `json:"centralServerVmId,omitempty"` + ManagedRgStorageAccountName *string `json:"managedRgStorageAccountName,omitempty"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DiscoveryConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DiscoveryConfiguration{} + +func (s DiscoveryConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DiscoveryConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DiscoveryConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DiscoveryConfiguration: %+v", err) + } + + decoded["configurationType"] = "Discovery" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DiscoveryConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go new file mode 100644 index 00000000000..b9fada01e2e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskConfiguration struct { + DiskVolumeConfigurations *map[string]DiskVolumeConfiguration `json:"diskVolumeConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go new file mode 100644 index 00000000000..19e1caae1c2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go @@ -0,0 +1,14 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + DiskTier *string `json:"diskTier,omitempty"` + IopsReadWrite *int64 `json:"iopsReadWrite,omitempty"` + MaximumSupportedDiskCount *int64 `json:"maximumSupportedDiskCount,omitempty"` + MbpsReadWrite *int64 `json:"mbpsReadWrite,omitempty"` + MinimumSupportedDiskCount *int64 `json:"minimumSupportedDiskCount,omitempty"` + SizeGB *int64 `json:"sizeGB,omitempty"` + Sku *DiskSku `json:"sku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go new file mode 100644 index 00000000000..4ad14b3416e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskSku struct { + Name *DiskSkuName `json:"name,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go new file mode 100644 index 00000000000..ddc92a369c7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskVolumeConfiguration struct { + Count *int64 `json:"count,omitempty"` + SizeGB *int64 `json:"sizeGB,omitempty"` + Sku *DiskSku `json:"sku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..18c075c9e04 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go new file mode 100644 index 00000000000..becaed0cda3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go new file mode 100644 index 00000000000..23a41b56090 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go new file mode 100644 index 00000000000..5e0b4faacb7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = ExternalInstallationSoftwareConfiguration{} + +type ExternalInstallationSoftwareConfiguration struct { + CentralServerVMId *string `json:"centralServerVmId,omitempty"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s ExternalInstallationSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = ExternalInstallationSoftwareConfiguration{} + +func (s ExternalInstallationSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ExternalInstallationSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "External" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go new file mode 100644 index 00000000000..efbdf413150 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 FileShareConfiguration interface { + FileShareConfiguration() BaseFileShareConfigurationImpl +} + +var _ FileShareConfiguration = BaseFileShareConfigurationImpl{} + +type BaseFileShareConfigurationImpl struct { + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s BaseFileShareConfigurationImpl) FileShareConfiguration() BaseFileShareConfigurationImpl { + return s +} + +var _ FileShareConfiguration = RawFileShareConfigurationImpl{} + +// RawFileShareConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFileShareConfigurationImpl struct { + fileShareConfiguration BaseFileShareConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawFileShareConfigurationImpl) FileShareConfiguration() BaseFileShareConfigurationImpl { + return s.fileShareConfiguration +} + +func UnmarshalFileShareConfigurationImplementation(input []byte) (FileShareConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling FileShareConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["configurationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CreateAndMount") { + var out CreateAndMountFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CreateAndMountFileShareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Mount") { + var out MountFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MountFileShareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Skip") { + var out SkipFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SkipFileShareConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseFileShareConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFileShareConfigurationImpl: %+v", err) + } + + return RawFileShareConfigurationImpl{ + fileShareConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go new file mode 100644 index 00000000000..d9ce01fc8b1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailabilityConfiguration struct { + HighAvailabilityType SAPHighAvailabilityType `json:"highAvailabilityType"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go new file mode 100644 index 00000000000..8d8583b37b3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailabilitySoftwareConfiguration struct { + FencingClientId string `json:"fencingClientId"` + FencingClientPassword string `json:"fencingClientPassword"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go new file mode 100644 index 00000000000..4f1ac0a149b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageReference struct { + Id *string `json:"id,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go new file mode 100644 index 00000000000..138f40f4a24 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go @@ -0,0 +1,84 @@ +package sapvirtualinstances + +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 InfrastructureConfiguration interface { + InfrastructureConfiguration() BaseInfrastructureConfigurationImpl +} + +var _ InfrastructureConfiguration = BaseInfrastructureConfigurationImpl{} + +type BaseInfrastructureConfigurationImpl struct { + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s BaseInfrastructureConfigurationImpl) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return s +} + +var _ InfrastructureConfiguration = RawInfrastructureConfigurationImpl{} + +// RawInfrastructureConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawInfrastructureConfigurationImpl struct { + infrastructureConfiguration BaseInfrastructureConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawInfrastructureConfigurationImpl) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return s.infrastructureConfiguration +} + +func UnmarshalInfrastructureConfigurationImplementation(input []byte) (InfrastructureConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling InfrastructureConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["deploymentType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SingleServer") { + var out SingleServerConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ThreeTier") { + var out ThreeTierConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseInfrastructureConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseInfrastructureConfigurationImpl: %+v", err) + } + + return RawInfrastructureConfigurationImpl{ + infrastructureConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go new file mode 100644 index 00000000000..3e39988ded8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go @@ -0,0 +1,52 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OSConfiguration = LinuxConfiguration{} + +type LinuxConfiguration struct { + DisablePasswordAuthentication *bool `json:"disablePasswordAuthentication,omitempty"` + Ssh *SshConfiguration `json:"ssh,omitempty"` + SshKeyPair *SshKeyPair `json:"sshKeyPair,omitempty"` + + // Fields inherited from OSConfiguration + + OsType OSType `json:"osType"` +} + +func (s LinuxConfiguration) OSConfiguration() BaseOSConfigurationImpl { + return BaseOSConfigurationImpl{ + OsType: s.OsType, + } +} + +var _ json.Marshaler = LinuxConfiguration{} + +func (s LinuxConfiguration) MarshalJSON() ([]byte, error) { + type wrapper LinuxConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LinuxConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LinuxConfiguration: %+v", err) + } + + decoded["osType"] = "Linux" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LinuxConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go new file mode 100644 index 00000000000..7789f0e8351 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go @@ -0,0 +1,11 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerResourceNames struct { + BackendPoolNames *[]string `json:"backendPoolNames,omitempty"` + FrontendIPConfigurationNames *[]string `json:"frontendIpConfigurationNames,omitempty"` + HealthProbeNames *[]string `json:"healthProbeNames,omitempty"` + LoadBalancerName *string `json:"loadBalancerName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go new file mode 100644 index 00000000000..8d7002377ff --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRGConfiguration struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go new file mode 100644 index 00000000000..12b9d933808 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go @@ -0,0 +1,51 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = MountFileShareConfiguration{} + +type MountFileShareConfiguration struct { + Id string `json:"id"` + PrivateEndpointId string `json:"privateEndpointId"` + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s MountFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = MountFileShareConfiguration{} + +func (s MountFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper MountFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MountFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MountFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "Mount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MountFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go new file mode 100644 index 00000000000..3805e428087 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfiguration struct { + IsSecondaryIPEnabled *bool `json:"isSecondaryIpEnabled,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go new file mode 100644 index 00000000000..0116cdb0dc2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceResourceNames struct { + NetworkInterfaceName *string `json:"networkInterfaceName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..723b60a69e6 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapvirtualinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go new file mode 100644 index 00000000000..53ac3199476 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go @@ -0,0 +1,83 @@ +package sapvirtualinstances + +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 OSConfiguration interface { + OSConfiguration() BaseOSConfigurationImpl +} + +var _ OSConfiguration = BaseOSConfigurationImpl{} + +type BaseOSConfigurationImpl struct { + OsType OSType `json:"osType"` +} + +func (s BaseOSConfigurationImpl) OSConfiguration() BaseOSConfigurationImpl { + return s +} + +var _ OSConfiguration = RawOSConfigurationImpl{} + +// RawOSConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawOSConfigurationImpl struct { + oSConfiguration BaseOSConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawOSConfigurationImpl) OSConfiguration() BaseOSConfigurationImpl { + return s.oSConfiguration +} + +func UnmarshalOSConfigurationImplementation(input []byte) (OSConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling OSConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["osType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Linux") { + var out LinuxConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LinuxConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out WindowsConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into WindowsConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseOSConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOSConfigurationImpl: %+v", err) + } + + return RawOSConfigurationImpl{ + oSConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go new file mode 100644 index 00000000000..5b4cba4ab6f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go @@ -0,0 +1,45 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + OsConfiguration OSConfiguration `json:"osConfiguration"` +} + +var _ json.Unmarshaler = &OSProfile{} + +func (s *OSProfile) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AdminPassword = decoded.AdminPassword + s.AdminUsername = decoded.AdminUsername + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling OSProfile into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["osConfiguration"]; ok { + impl, err := UnmarshalOSConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'OsConfiguration' for 'OSProfile': %+v", err) + } + s.OsConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go new file mode 100644 index 00000000000..d5a1d18b285 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsSapConfiguration struct { + DeployerVMPackages *DeployerVMPackages `json:"deployerVmPackages,omitempty"` + SapFqdn *string `json:"sapFqdn,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go new file mode 100644 index 00000000000..3002b1dcd82 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZoneDetailsRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go new file mode 100644 index 00000000000..88a3556f5c5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZoneDetailsResult struct { + AvailabilityZonePairs *[]SAPAvailabilityZonePair `json:"availabilityZonePairs,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go new file mode 100644 index 00000000000..3c18d72d02d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZonePair struct { + ZoneA *int64 `json:"zoneA,omitempty"` + ZoneB *int64 `json:"zoneB,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go new file mode 100644 index 00000000000..776e6a14fc5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 SAPConfiguration interface { + SAPConfiguration() BaseSAPConfigurationImpl +} + +var _ SAPConfiguration = BaseSAPConfigurationImpl{} + +type BaseSAPConfigurationImpl struct { + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s BaseSAPConfigurationImpl) SAPConfiguration() BaseSAPConfigurationImpl { + return s +} + +var _ SAPConfiguration = RawSAPConfigurationImpl{} + +// RawSAPConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSAPConfigurationImpl struct { + sAPConfiguration BaseSAPConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawSAPConfigurationImpl) SAPConfiguration() BaseSAPConfigurationImpl { + return s.sAPConfiguration +} + +func UnmarshalSAPConfigurationImplementation(input []byte) (SAPConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SAPConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["configurationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Deployment") { + var out DeploymentConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeploymentConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeploymentWithOSConfig") { + var out DeploymentWithOSConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeploymentWithOSConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Discovery") { + var out DiscoveryConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DiscoveryConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseSAPConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSAPConfigurationImpl: %+v", err) + } + + return RawSAPConfigurationImpl{ + sAPConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go new file mode 100644 index 00000000000..e1ee5988200 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfiguration struct { + RecommendedConfiguration *DiskVolumeConfiguration `json:"recommendedConfiguration,omitempty"` + SupportedConfigurations *[]DiskDetails `json:"supportedConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go new file mode 100644 index 00000000000..743d843fa54 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go @@ -0,0 +1,13 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfigurationsRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DbVMSku string `json:"dbVmSku"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go new file mode 100644 index 00000000000..f40e340ae21 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfigurationsResult struct { + VolumeConfigurations *map[string]SAPDiskConfiguration `json:"volumeConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go new file mode 100644 index 00000000000..14cfc6b9ba8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = SAPInstallWithoutOSConfigSoftwareConfiguration{} + +type SAPInstallWithoutOSConfigSoftwareConfiguration struct { + BomURL string `json:"bomUrl"` + HighAvailabilitySoftwareConfiguration *HighAvailabilitySoftwareConfiguration `json:"highAvailabilitySoftwareConfiguration,omitempty"` + SapBitsStorageAccountId string `json:"sapBitsStorageAccountId"` + SoftwareVersion string `json:"softwareVersion"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s SAPInstallWithoutOSConfigSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = SAPInstallWithoutOSConfigSoftwareConfiguration{} + +func (s SAPInstallWithoutOSConfigSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SAPInstallWithoutOSConfigSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "SAPInstallWithoutOSConfig" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go new file mode 100644 index 00000000000..3ddb3c14444 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go @@ -0,0 +1,16 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSizingRecommendationRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DbMemory int64 `json:"dbMemory"` + DbScaleMethod *SAPDatabaseScaleMethod `json:"dbScaleMethod,omitempty"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + HighAvailabilityType *SAPHighAvailabilityType `json:"highAvailabilityType,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + Saps int64 `json:"saps"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go new file mode 100644 index 00000000000..187e7a164ee --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go @@ -0,0 +1,83 @@ +package sapvirtualinstances + +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 SAPSizingRecommendationResult interface { + SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl +} + +var _ SAPSizingRecommendationResult = BaseSAPSizingRecommendationResultImpl{} + +type BaseSAPSizingRecommendationResultImpl struct { + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s BaseSAPSizingRecommendationResultImpl) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return s +} + +var _ SAPSizingRecommendationResult = RawSAPSizingRecommendationResultImpl{} + +// RawSAPSizingRecommendationResultImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSAPSizingRecommendationResultImpl struct { + sAPSizingRecommendationResult BaseSAPSizingRecommendationResultImpl + Type string + Values map[string]interface{} +} + +func (s RawSAPSizingRecommendationResultImpl) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return s.sAPSizingRecommendationResult +} + +func UnmarshalSAPSizingRecommendationResultImplementation(input []byte) (SAPSizingRecommendationResult, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SAPSizingRecommendationResult into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["deploymentType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SingleServer") { + var out SingleServerRecommendationResult + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerRecommendationResult: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ThreeTier") { + var out ThreeTierRecommendationResult + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierRecommendationResult: %+v", err) + } + return out, nil + } + + var parent BaseSAPSizingRecommendationResultImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSAPSizingRecommendationResultImpl: %+v", err) + } + + return RawSAPSizingRecommendationResultImpl{ + sAPSizingRecommendationResult: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go new file mode 100644 index 00000000000..0fdd3d4be10 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedResourceSkusResult struct { + SupportedSkus *[]SAPSupportedSku `json:"supportedSkus,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go new file mode 100644 index 00000000000..d04c2328462 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedSku struct { + IsAppServerCertified *bool `json:"isAppServerCertified,omitempty"` + IsDatabaseCertified *bool `json:"isDatabaseCertified,omitempty"` + VMSku *string `json:"vmSku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go new file mode 100644 index 00000000000..3e24c4c3d59 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go @@ -0,0 +1,13 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedSkusRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + HighAvailabilityType *SAPHighAvailabilityType `json:"highAvailabilityType,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go new file mode 100644 index 00000000000..6ca7eaa18d8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go @@ -0,0 +1,20 @@ +package sapvirtualinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "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 SAPVirtualInstance struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPVirtualInstanceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..b473f684fcc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go new file mode 100644 index 00000000000..a60c5700024 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go @@ -0,0 +1,66 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceProperties struct { + Configuration SAPConfiguration `json:"configuration"` + Environment SAPEnvironmentType `json:"environment"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + ManagedResourceGroupConfiguration *ManagedRGConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + State *SAPVirtualInstanceState `json:"state,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` +} + +var _ json.Unmarshaler = &SAPVirtualInstanceProperties{} + +func (s *SAPVirtualInstanceProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Environment SAPEnvironmentType `json:"environment"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + ManagedResourceGroupConfiguration *ManagedRGConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + State *SAPVirtualInstanceState `json:"state,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Environment = decoded.Environment + s.Errors = decoded.Errors + s.Health = decoded.Health + s.ManagedResourceGroupConfiguration = decoded.ManagedResourceGroupConfiguration + s.ManagedResourcesNetworkAccessType = decoded.ManagedResourcesNetworkAccessType + s.ProvisioningState = decoded.ProvisioningState + s.SapProduct = decoded.SapProduct + s.State = decoded.State + s.Status = decoded.Status + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SAPVirtualInstanceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["configuration"]; ok { + impl, err := UnmarshalSAPConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Configuration' for 'SAPVirtualInstanceProperties': %+v", err) + } + s.Configuration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go new file mode 100644 index 00000000000..0f1ff942c7f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go @@ -0,0 +1,55 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = ServiceInitiatedSoftwareConfiguration{} + +type ServiceInitiatedSoftwareConfiguration struct { + BomURL string `json:"bomUrl"` + HighAvailabilitySoftwareConfiguration *HighAvailabilitySoftwareConfiguration `json:"highAvailabilitySoftwareConfiguration,omitempty"` + SapBitsStorageAccountId string `json:"sapBitsStorageAccountId"` + SapFqdn string `json:"sapFqdn"` + SoftwareVersion string `json:"softwareVersion"` + SshPrivateKey string `json:"sshPrivateKey"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s ServiceInitiatedSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = ServiceInitiatedSoftwareConfiguration{} + +func (s ServiceInitiatedSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ServiceInitiatedSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "ServiceInitiated" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go new file mode 100644 index 00000000000..0a5c9dd1dda --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedStorageResourceNames struct { + SharedStorageAccountName *string `json:"sharedStorageAccountName,omitempty"` + SharedStorageAccountPrivateEndPointName *string `json:"sharedStorageAccountPrivateEndPointName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go new file mode 100644 index 00000000000..0b4d0c8b665 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go @@ -0,0 +1,97 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ InfrastructureConfiguration = SingleServerConfiguration{} + +type SingleServerConfiguration struct { + CustomResourceNames SingleServerCustomResourceNames `json:"customResourceNames"` + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DbDiskConfiguration *DiskConfiguration `json:"dbDiskConfiguration,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` + + // Fields inherited from InfrastructureConfiguration + + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s SingleServerConfiguration) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return BaseInfrastructureConfigurationImpl{ + AppResourceGroup: s.AppResourceGroup, + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = SingleServerConfiguration{} + +func (s SingleServerConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SingleServerConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerConfiguration: %+v", err) + } + + decoded["deploymentType"] = "SingleServer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SingleServerConfiguration{} + +func (s *SingleServerConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DbDiskConfiguration *DiskConfiguration `json:"dbDiskConfiguration,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DatabaseType = decoded.DatabaseType + s.DbDiskConfiguration = decoded.DbDiskConfiguration + s.NetworkConfiguration = decoded.NetworkConfiguration + s.SubnetId = decoded.SubnetId + s.VirtualMachineConfiguration = decoded.VirtualMachineConfiguration + s.AppResourceGroup = decoded.AppResourceGroup + s.DeploymentType = decoded.DeploymentType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SingleServerConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customResourceNames"]; ok { + impl, err := UnmarshalSingleServerCustomResourceNamesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomResourceNames' for 'SingleServerConfiguration': %+v", err) + } + s.CustomResourceNames = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go new file mode 100644 index 00000000000..0004c02b979 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 SingleServerCustomResourceNames interface { + SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl +} + +var _ SingleServerCustomResourceNames = BaseSingleServerCustomResourceNamesImpl{} + +type BaseSingleServerCustomResourceNamesImpl struct { + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s BaseSingleServerCustomResourceNamesImpl) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return s +} + +var _ SingleServerCustomResourceNames = RawSingleServerCustomResourceNamesImpl{} + +// RawSingleServerCustomResourceNamesImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSingleServerCustomResourceNamesImpl struct { + singleServerCustomResourceNames BaseSingleServerCustomResourceNamesImpl + Type string + Values map[string]interface{} +} + +func (s RawSingleServerCustomResourceNamesImpl) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return s.singleServerCustomResourceNames +} + +func UnmarshalSingleServerCustomResourceNamesImplementation(input []byte) (SingleServerCustomResourceNames, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerCustomResourceNames into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["namingPatternType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FullResourceName") { + var out SingleServerFullResourceNames + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerFullResourceNames: %+v", err) + } + return out, nil + } + + var parent BaseSingleServerCustomResourceNamesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSingleServerCustomResourceNamesImpl: %+v", err) + } + + return RawSingleServerCustomResourceNamesImpl{ + singleServerCustomResourceNames: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go new file mode 100644 index 00000000000..b33a1da3d75 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SingleServerCustomResourceNames = SingleServerFullResourceNames{} + +type SingleServerFullResourceNames struct { + VirtualMachine *VirtualMachineResourceNames `json:"virtualMachine,omitempty"` + + // Fields inherited from SingleServerCustomResourceNames + + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s SingleServerFullResourceNames) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return BaseSingleServerCustomResourceNamesImpl{ + NamingPatternType: s.NamingPatternType, + } +} + +var _ json.Marshaler = SingleServerFullResourceNames{} + +func (s SingleServerFullResourceNames) MarshalJSON() ([]byte, error) { + type wrapper SingleServerFullResourceNames + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerFullResourceNames: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerFullResourceNames: %+v", err) + } + + decoded["namingPatternType"] = "FullResourceName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerFullResourceNames: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go new file mode 100644 index 00000000000..4a39f4fee2a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPSizingRecommendationResult = SingleServerRecommendationResult{} + +type SingleServerRecommendationResult struct { + VMSku *string `json:"vmSku,omitempty"` + + // Fields inherited from SAPSizingRecommendationResult + + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s SingleServerRecommendationResult) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return BaseSAPSizingRecommendationResultImpl{ + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = SingleServerRecommendationResult{} + +func (s SingleServerRecommendationResult) MarshalJSON() ([]byte, error) { + type wrapper SingleServerRecommendationResult + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerRecommendationResult: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerRecommendationResult: %+v", err) + } + + decoded["deploymentType"] = "SingleServer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerRecommendationResult: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go new file mode 100644 index 00000000000..dc6b71ff635 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go @@ -0,0 +1,49 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = SkipFileShareConfiguration{} + +type SkipFileShareConfiguration struct { + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s SkipFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = SkipFileShareConfiguration{} + +func (s SkipFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SkipFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SkipFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SkipFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "Skip" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SkipFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go new file mode 100644 index 00000000000..79d4059c6d0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 SoftwareConfiguration interface { + SoftwareConfiguration() BaseSoftwareConfigurationImpl +} + +var _ SoftwareConfiguration = BaseSoftwareConfigurationImpl{} + +type BaseSoftwareConfigurationImpl struct { + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s BaseSoftwareConfigurationImpl) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return s +} + +var _ SoftwareConfiguration = RawSoftwareConfigurationImpl{} + +// RawSoftwareConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSoftwareConfigurationImpl struct { + softwareConfiguration BaseSoftwareConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawSoftwareConfigurationImpl) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return s.softwareConfiguration +} + +func UnmarshalSoftwareConfigurationImplementation(input []byte) (SoftwareConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SoftwareConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["softwareInstallationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "External") { + var out ExternalInstallationSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExternalInstallationSoftwareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPInstallWithoutOSConfig") { + var out SAPInstallWithoutOSConfigSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServiceInitiated") { + var out ServiceInitiatedSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServiceInitiatedSoftwareConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseSoftwareConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSoftwareConfigurationImpl: %+v", err) + } + + return RawSoftwareConfigurationImpl{ + softwareConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go new file mode 100644 index 00000000000..8aa35391df6 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshConfiguration struct { + PublicKeys *[]SshPublicKey `json:"publicKeys,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go new file mode 100644 index 00000000000..c8c9f86c535 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshKeyPair struct { + PrivateKey *string `json:"privateKey,omitempty"` + PublicKey *string `json:"publicKey,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go new file mode 100644 index 00000000000..4bd50069431 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshPublicKey struct { + KeyData *string `json:"keyData,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go new file mode 100644 index 00000000000..9c7466742e9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go new file mode 100644 index 00000000000..08a49608fc9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go new file mode 100644 index 00000000000..ec178033530 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go @@ -0,0 +1,33 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageConfiguration struct { + TransportFileShareConfiguration FileShareConfiguration `json:"transportFileShareConfiguration"` +} + +var _ json.Unmarshaler = &StorageConfiguration{} + +func (s *StorageConfiguration) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StorageConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["transportFileShareConfiguration"]; ok { + impl, err := UnmarshalFileShareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TransportFileShareConfiguration' for 'StorageConfiguration': %+v", err) + } + s.TransportFileShareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go new file mode 100644 index 00000000000..19f94f63f0a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go @@ -0,0 +1,100 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ InfrastructureConfiguration = ThreeTierConfiguration{} + +type ThreeTierConfiguration struct { + ApplicationServer ApplicationServerConfiguration `json:"applicationServer"` + CentralServer CentralServerConfiguration `json:"centralServer"` + CustomResourceNames ThreeTierCustomResourceNames `json:"customResourceNames"` + DatabaseServer DatabaseConfiguration `json:"databaseServer"` + HighAvailabilityConfig *HighAvailabilityConfiguration `json:"highAvailabilityConfig,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + StorageConfiguration *StorageConfiguration `json:"storageConfiguration,omitempty"` + + // Fields inherited from InfrastructureConfiguration + + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s ThreeTierConfiguration) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return BaseInfrastructureConfigurationImpl{ + AppResourceGroup: s.AppResourceGroup, + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = ThreeTierConfiguration{} + +func (s ThreeTierConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierConfiguration: %+v", err) + } + + decoded["deploymentType"] = "ThreeTier" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ThreeTierConfiguration{} + +func (s *ThreeTierConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ApplicationServer ApplicationServerConfiguration `json:"applicationServer"` + CentralServer CentralServerConfiguration `json:"centralServer"` + DatabaseServer DatabaseConfiguration `json:"databaseServer"` + HighAvailabilityConfig *HighAvailabilityConfiguration `json:"highAvailabilityConfig,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + StorageConfiguration *StorageConfiguration `json:"storageConfiguration,omitempty"` + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ApplicationServer = decoded.ApplicationServer + s.CentralServer = decoded.CentralServer + s.DatabaseServer = decoded.DatabaseServer + s.HighAvailabilityConfig = decoded.HighAvailabilityConfig + s.NetworkConfiguration = decoded.NetworkConfiguration + s.StorageConfiguration = decoded.StorageConfiguration + s.AppResourceGroup = decoded.AppResourceGroup + s.DeploymentType = decoded.DeploymentType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ThreeTierConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customResourceNames"]; ok { + impl, err := UnmarshalThreeTierCustomResourceNamesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomResourceNames' for 'ThreeTierConfiguration': %+v", err) + } + s.CustomResourceNames = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go new file mode 100644 index 00000000000..da72d08566f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 ThreeTierCustomResourceNames interface { + ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl +} + +var _ ThreeTierCustomResourceNames = BaseThreeTierCustomResourceNamesImpl{} + +type BaseThreeTierCustomResourceNamesImpl struct { + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s BaseThreeTierCustomResourceNamesImpl) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return s +} + +var _ ThreeTierCustomResourceNames = RawThreeTierCustomResourceNamesImpl{} + +// RawThreeTierCustomResourceNamesImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawThreeTierCustomResourceNamesImpl struct { + threeTierCustomResourceNames BaseThreeTierCustomResourceNamesImpl + Type string + Values map[string]interface{} +} + +func (s RawThreeTierCustomResourceNamesImpl) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return s.threeTierCustomResourceNames +} + +func UnmarshalThreeTierCustomResourceNamesImplementation(input []byte) (ThreeTierCustomResourceNames, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierCustomResourceNames into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["namingPatternType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FullResourceName") { + var out ThreeTierFullResourceNames + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierFullResourceNames: %+v", err) + } + return out, nil + } + + var parent BaseThreeTierCustomResourceNamesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseThreeTierCustomResourceNamesImpl: %+v", err) + } + + return RawThreeTierCustomResourceNamesImpl{ + threeTierCustomResourceNames: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go new file mode 100644 index 00000000000..01be320e9ba --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ThreeTierCustomResourceNames = ThreeTierFullResourceNames{} + +type ThreeTierFullResourceNames struct { + ApplicationServer *ApplicationServerFullResourceNames `json:"applicationServer,omitempty"` + CentralServer *CentralServerFullResourceNames `json:"centralServer,omitempty"` + DatabaseServer *DatabaseServerFullResourceNames `json:"databaseServer,omitempty"` + SharedStorage *SharedStorageResourceNames `json:"sharedStorage,omitempty"` + + // Fields inherited from ThreeTierCustomResourceNames + + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s ThreeTierFullResourceNames) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return BaseThreeTierCustomResourceNamesImpl{ + NamingPatternType: s.NamingPatternType, + } +} + +var _ json.Marshaler = ThreeTierFullResourceNames{} + +func (s ThreeTierFullResourceNames) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierFullResourceNames + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierFullResourceNames: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierFullResourceNames: %+v", err) + } + + decoded["namingPatternType"] = "FullResourceName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierFullResourceNames: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go new file mode 100644 index 00000000000..6a4a5108da1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go @@ -0,0 +1,55 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPSizingRecommendationResult = ThreeTierRecommendationResult{} + +type ThreeTierRecommendationResult struct { + ApplicationServerInstanceCount *int64 `json:"applicationServerInstanceCount,omitempty"` + ApplicationServerVMSku *string `json:"applicationServerVmSku,omitempty"` + CentralServerInstanceCount *int64 `json:"centralServerInstanceCount,omitempty"` + CentralServerVMSku *string `json:"centralServerVmSku,omitempty"` + DatabaseInstanceCount *int64 `json:"databaseInstanceCount,omitempty"` + DbVMSku *string `json:"dbVmSku,omitempty"` + + // Fields inherited from SAPSizingRecommendationResult + + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s ThreeTierRecommendationResult) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return BaseSAPSizingRecommendationResultImpl{ + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = ThreeTierRecommendationResult{} + +func (s ThreeTierRecommendationResult) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierRecommendationResult + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierRecommendationResult: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierRecommendationResult: %+v", err) + } + + decoded["deploymentType"] = "ThreeTier" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierRecommendationResult: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go new file mode 100644 index 00000000000..d956979e1b3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPVirtualInstanceProperties struct { + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go new file mode 100644 index 00000000000..95da3bf4f6e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go @@ -0,0 +1,14 @@ +package sapvirtualinstances + +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 UpdateSAPVirtualInstanceRequest struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *UpdateSAPVirtualInstanceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go new file mode 100644 index 00000000000..ec4bdf513ab --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineConfiguration struct { + ImageReference ImageReference `json:"imageReference"` + OsProfile OSProfile `json:"osProfile"` + VMSize string `json:"vmSize"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go new file mode 100644 index 00000000000..a9767d0a758 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineResourceNames struct { + DataDiskNames *map[string][]string `json:"dataDiskNames,omitempty"` + HostName *string `json:"hostName,omitempty"` + NetworkInterfaces *[]NetworkInterfaceResourceNames `json:"networkInterfaces,omitempty"` + OsDiskName *string `json:"osDiskName,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go new file mode 100644 index 00000000000..81f41dff686 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go @@ -0,0 +1,49 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OSConfiguration = WindowsConfiguration{} + +type WindowsConfiguration struct { + + // Fields inherited from OSConfiguration + + OsType OSType `json:"osType"` +} + +func (s WindowsConfiguration) OSConfiguration() BaseOSConfigurationImpl { + return BaseOSConfigurationImpl{ + OsType: s.OsType, + } +} + +var _ json.Marshaler = WindowsConfiguration{} + +func (s WindowsConfiguration) MarshalJSON() ([]byte, error) { + type wrapper WindowsConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling WindowsConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling WindowsConfiguration: %+v", err) + } + + decoded["osType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling WindowsConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go new file mode 100644 index 00000000000..7b18cd9294a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go @@ -0,0 +1,32 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPVirtualInstanceOperationPredicate) Matches(input SAPVirtualInstance) 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/resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go new file mode 100644 index 00000000000..6793a56243f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapvirtualinstances/2024-09-01" +}